Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22248

clang9(or trunk) vs gcc9: member array size as non-type template parameter [duplicate]

$
0
0

I have the following mock code

#include <array>
template<int N>
struct S {
    std::array<int, N> m{};
};

template<int N>
auto copy (S<N> const& i) {
    return S<i.m.size()>{};
}

int main() {
    copy(S<1>{});
}

Is i.m.size() supposed to be a valid non-type template parameter?
clang9 sais no, gcc9 sais yes: https://godbolt.org/z/PoHjH8

I kind of "get" clang because i is not constexpr, but since the i.m.size() is still known at compile time, gcc's approach makes more sense to me.
Who is correct here?


Viewing all articles
Browse latest Browse all 22248

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>