Sujet : clang and gcc are not converging on constexpr
De : thiago.adams (at) *nospam* gmail.com (Thiago Adams)
Groupes : comp.lang.cDate : 07. Nov 2024, 20:16:49
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vgj3n1$2pbqp$1@dont-email.me>
User-Agent : Mozilla Thunderbird
The differences relate to arrays. I think the standard leaves some flexibility in the specification, so there may not be a strict right or wrong - just different approaches. The challenge for creating portable code is knowing when it will work consistently across different compilers.
Sample
int main() {
constexpr int a[] = {1, 2};
static_assert(a[0] == 1);
}
works in clang but not in gcc