This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/45113] absent or confusing diagnostics of invalid template argument list in implicit template class instantiation


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45113

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-08-14
                 CC|                            |egallager at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Roman Kononov from comment #0)
> $cat test1.cpp
> template<typename X,typename Y> struct is_same { static bool const
> value=false; };
> template<typename X> struct is_same<X,X> { static bool const value=true; };
> template<typename... X> struct U {};
> struct Q { typedef U<int x,int y> C; };
> typedef char check[is_same<int,Q::C>::value ? 1 : -1];
> 
> $g++ -std=gnu++0x -c test1.cpp && echo $?
> 0
> 
> In 14.3.1, the Standard says: "A template-argument for a template-parameter
> which is a type shall be a type-id." The test must fail compilation, and
> Q::C can not be int.

This now fails with:
$ /usr/local/bin/g++ -c -std=gnu++0x 45113.cc
45113.cc:4:33: error: template argument 1 is invalid
 struct Q { typedef U<int x,int y> C; };
                                 ^
$

> 
> $cat test2.cpp
> template<typename... X> struct U {};
> typedef U<int x,int y> B;
> 
> $g++ -std=gnu++0x -c test2.cpp 
> test2.cpp:2:25: error: invalid type in declaration before ';' token
> 
> This message is confusing.

This message is now:
$ /usr/local/bin/g++ -c -std=gnu++0x 45113_2.cc
45113_2.cc:2:22: error: template argument 1 is invalid
 typedef U<int x,int y> B;
                      ^
$

> 
> $cat test3.cpp 
> template<typename X,typename Y> struct U {};
> typedef U<int x,int y> A;
> 
> $g++ -c test3.cpp 
> test3.cpp:2:22: error: wrong number of template arguments (1, should be 2)
> test3.cpp:1:40: error: provided for 'template<class X, class Y> struct U'
> test3.cpp:2:25: error: invalid type in declaration before ';' token
> 
> These messages are confusing.

This message is now:
$ /usr/local/bin/g++ -c -std=gnu++0x 45113_3.cc
45113_3.cc:2:22: error: wrong number of template arguments (1, should be 2)
 typedef U<int x,int y> A;
                      ^
45113_3.cc:1:40: note: provided for ‘template<class X, class Y> struct U’
 template<typename X,typename Y> struct U {};
                                        ^
$

Which I guess is still kinda confusing. So test1.cpp and test2.cpp are fixed,
but confirming for test3.cpp.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]