Array size validity and SFINAE

Liste des GroupesRevenir à cl c++ 
Sujet : Array size validity and SFINAE
De : noone (at) *nospam* noone.net (Andrey Tarasevich)
Groupes : comp.lang.c++
Date : 25. Feb 2026, 17:08:25
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <10nn6pp$su58$1@dont-email.me>
User-Agent : Mozilla Thunderbird
   #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

Date Sujet#  Auteur
25 Feb 26 * Array size validity and SFINAE9Andrey Tarasevich
1 Mar 26 +* Re: Array size validity and SFINAE5Marcel Mueller
1 Mar 26 i+* Re: Array size validity and SFINAE3Andrey Tarasevich
2 Mar 26 ii`* Re: Array size validity and SFINAE2Chris M. Thomasson
2 Mar 26 ii `- Re: Array size validity and SFINAE1Andrey Tarasevich
2 Mar 26 i`- Re: Array size validity and SFINAE1Bonita Montero
2 Mar 26 `* Re: Array size validity and SFINAE3Tim Rentsch
2 Mar 26  `* Re: Array size validity and SFINAE2Andrey Tarasevich
3 Mar 26   `- Re: Array size validity and SFINAE1Tim Rentsch

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal