Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #123494
| From | Andrey Tarasevich <noone@noone.net> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Array size validity and SFINAE |
| Date | 2026-02-25 08:08 -0800 |
| Organization | A noiseless patient Spider |
| Message-ID | <10nn6pp$su58$1@dont-email.me> (permalink) |
#include <iostream>
struct S { static constexpr int N = -1; };
template <typename T> void foo(int [T::N])
{
std::cout << "array" << std::endl;
}
template <typename T> void foo(...)
{
std::cout << "..." << std::endl;
}
int main()
{
foo<int>(0);
}
GCC outputs "array", Clang and MSVC output "..."
The struct definition can be changed to `struct S {};` with the same
behavior from GCC. I.e. in template contexts GCC does not check the
validity of the size specified in array parameter declaration: it
doesn't care whether it is positive, it doesn't even care whether the
nested name exists. One can guess that this is most likely a consequence
of the array parameter type adjustment, which makes the size essentially
"disappear". However, it still does not necessarily mean that such array
parameter declaration should be accepted as valid.
So, who's right here standard-wise?
--
Best regards,
Andrey
Back to comp.lang.c++ | Previous | Next — Next in thread | Find similar | Unroll thread
Array size validity and SFINAE Andrey Tarasevich <noone@noone.net> - 2026-02-25 08:08 -0800
Re: Array size validity and SFINAE Marcel Mueller <news.5.maazl@spamgourmet.org> - 2026-03-01 16:55 +0100
Re: Array size validity and SFINAE Andrey Tarasevich <noone@noone.net> - 2026-03-01 08:23 -0800
Re: Array size validity and SFINAE "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-03-01 16:36 -0800
Re: Array size validity and SFINAE Andrey Tarasevich <noone@noone.net> - 2026-03-01 16:45 -0800
Re: Array size validity and SFINAE Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-02 13:21 +0100
Re: Array size validity and SFINAE Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-02 00:38 -0800
Re: Array size validity and SFINAE Andrey Tarasevich <noone@noone.net> - 2026-03-02 07:48 -0800
Re: Array size validity and SFINAE Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-02 21:34 -0800
csiph-web