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++/10118] Bad diagnostic with cast in template argument expression


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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org
      Known to fail|                            |3.4.0, 4.5.3, 4.8.3, 4.9.3,
                   |                            |5.3.0, 6.3.0, 7.0

--- Comment #10 from Martin Sebor <msebor at gcc dot gnu.org> ---
For the test case in comment #2 GCC 7.0 print the following errors.  The
English text of the errors looks fine but the types are still pretty wacky:

$ cat t.C && /ssd/build/gcc-git-svn/gcc/xgcc -B /ssd/build/gcc-git-svn/gcc -S
-Wall -Wextra t.C
    struct A { void foo(); };
    struct B : A {};
    typedef void (B::*B_ptr) ();

    template <class T, void (T::* U)()>  struct CT {};

    CT<B, (B_ptr) &A::foo>  c;
t.C:7:26: error: ‘void (B::*)(){((void (B::*)())A::foo), (0 + 0)}’ is not a
valid template argument for type ‘void (B::*)()’
     CT<B, (B_ptr) &A::foo>  c;
                          ^
t.C:7:26: error: it must be a pointer-to-member of the form ‘&X::Y’
t.C:7:26: error: could not convert template argument ‘void (B::*)(){((void
(B::*)())A::foo), (0 + 0)}’ from ‘void (B::*)()’ to ‘void (B::*)()’


Clang 5.0 prints a much clearer error message:

t.C:7:11: error: non-type template argument is not a pointer to member constant
    CT<B, (B_ptr) &A::foo>  c;
          ^~~~~~~~~~~~~~~

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