public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/10118] Bad diagnostic with cast in template argument expression
[not found] <bug-10118-4@http.gcc.gnu.org/bugzilla/>
@ 2021-07-23 19:49 ` pinskia at gcc dot gnu.org
2024-04-04 0:08 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-23 19:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10118
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |101603
Last reconfirmed|2005-12-11 23:07:23 |2021-7-23
--- Comment #11 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
We get now:
<source>:7:26: error: 'void (B::*)(){((void (B::*)())A::foo), 0}' is not a
valid template argument for type 'void (B::*)()'
7 | CT<B, (B_ptr) &A::foo> c;
| ^
<source>:7:26: note: it must be a pointer-to-member of the form '&X::Y'
ASM generation compiler returned: 1
<source>:7:26: error: 'void (B::*)(){((void (B::*)())A::foo), 0}' is not a
valid template argument for type 'void (B::*)()'
7 | CT<B, (B_ptr) &A::foo> c;
| ^
<source>:7:26: note: it must be a pointer-to-member of the form '&X::Y'
Execution build compiler returned: 1
While clang produces:
<source>:7:11: error: non-type template argument is not a pointer to member
constant
CT<B, (B_ptr) &A::foo> c;
^~~~~~~~~~~~~~~
1 error generated.
ASM generation compiler returned: 1
<source>:7:11: error: non-type template argument is not a pointer to member
constant
CT<B, (B_ptr) &A::foo> c;
^~~~~~~~~~~~~~~
Both are not obvious but gcc is still worse as it has the "{((void
(B::*)())A::foo), 0}" part there still.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101603
[Bug 101603] [meta-bug] pointer to member functions issues
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/10118] Bad diagnostic with cast in template argument expression
[not found] <bug-10118-4@http.gcc.gnu.org/bugzilla/>
2021-07-23 19:49 ` [Bug c++/10118] Bad diagnostic with cast in template argument expression pinskia at gcc dot gnu.org
@ 2024-04-04 0:08 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-04 0:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10118
--- Comment #12 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Hmm, clang accepts this also for -std=c++17 (and above).
While EDG accepts this for --c++11 (and above).
Is this valid in C++11+ or C++17+ now?
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/10118] Bad diagnostic with cast in template argument expression
[not found] <20030317033600.10118.philippeb@videotron.ca>
` (2 preceding siblings ...)
2004-08-20 6:52 ` pinskia at gcc dot gnu dot org
@ 2004-08-20 7:12 ` gdr at integrable-solutions dot net
3 siblings, 0 replies; 6+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-08-20 7:12 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gdr at integrable-solutions dot net 2004-08-20 07:12 -------
Subject: Re: Bad diagnostic with cast in template argument expression
"pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:
| Slightly error message change:
| pr10118.cc:8: error: `A::foo()' cannot appear in a constant-expression
This is wrong and I know why. The code cp/error.c is too contrived to
fix it properly. It is better to rely on the code in
cp/cxx-pretty-print.c to fix it.
| pr10118.cc:8: error: `&' cannot appear in a constant-expression
This does nto make any sense.
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10118
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/10118] Bad diagnostic with cast in template argument expression
[not found] <20030317033600.10118.philippeb@videotron.ca>
2003-12-05 2:44 ` pinskia at gcc dot gnu dot org
2003-12-05 3:31 ` bangerth at dealii dot org
@ 2004-08-20 6:52 ` pinskia at gcc dot gnu dot org
2004-08-20 7:12 ` gdr at integrable-solutions dot net
3 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-20 6:52 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-08-20 06:52 -------
Slightly error message change:
pr10118.cc:8: error: `A::foo()' cannot appear in a constant-expression
pr10118.cc:8: error: `&' cannot appear in a constant-expression
pr10118.cc:8: error: a cast to a type other than an integral or enumeration type cannot appear in a
constant-expression
pr10118.cc:8: error: template argument 2 is invalid
pr10118.cc:8: error: invalid type in declaration before ';' token
--
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2004-05-21 03:50:25 |2004-08-20 06:52:50
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10118
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/10118] Bad diagnostic with cast in template argument expression
[not found] <20030317033600.10118.philippeb@videotron.ca>
2003-12-05 2:44 ` pinskia at gcc dot gnu dot org
@ 2003-12-05 3:31 ` bangerth at dealii dot org
2004-08-20 6:52 ` pinskia at gcc dot gnu dot org
2004-08-20 7:12 ` gdr at integrable-solutions dot net
3 siblings, 0 replies; 6+ messages in thread
From: bangerth at dealii dot org @ 2003-12-05 3:31 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2003-12-05 03:31 -------
I see two open issues here: first, the error message has wrong
grammar ("a cast_s_").
The second thing is that what is being attempted here doesn't seem
to be possible: neither of these work:
CT<B, &A::foo> c1;
CT<B, &B::foo> c2;
CT<B, (B_ptr)&B::foo> c3;
The second one is particularly confusing, since &B::foo immediately decays
to A::*, but this has recently been discussed in another PR and seems to
be standards conforming. The last one should cast this back, but this
isn't allowed. The first one should of course be wrong. So we are left
with a situation where something just can't be done. Someone should
file a DR for this, this is clearly a less than satisfactory situation...
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10118
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/10118] Bad diagnostic with cast in template argument expression
[not found] <20030317033600.10118.philippeb@videotron.ca>
@ 2003-12-05 2:44 ` pinskia at gcc dot gnu dot org
2003-12-05 3:31 ` bangerth at dealii dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-05 2:44 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2003-12-05 02:44 -------
this is semi-fixed on the mainline (get rid of the "()" and it would be considered fixed, unless
someone says otherwise. )
pr1011.cc:7: error: `A::foo()' cannot appear in a constant-expression
pr1011.cc:7: error: a casts to a type other than an integral or enumeration type cannot appear in a
constant-expression
pr1011.cc:7: error: template argument 2 is invalid
pr1011.cc:7: error: expected constructor, destructor, or type conversion
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |minor
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10118
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-04-04 0:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-10118-4@http.gcc.gnu.org/bugzilla/>
2021-07-23 19:49 ` [Bug c++/10118] Bad diagnostic with cast in template argument expression pinskia at gcc dot gnu.org
2024-04-04 0:08 ` pinskia at gcc dot gnu.org
[not found] <20030317033600.10118.philippeb@videotron.ca>
2003-12-05 2:44 ` pinskia at gcc dot gnu dot org
2003-12-05 3:31 ` bangerth at dealii dot org
2004-08-20 6:52 ` pinskia at gcc dot gnu dot org
2004-08-20 7:12 ` gdr at integrable-solutions dot net
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).