public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/46831] New: Crash when it tries to do an invalid ICS with a conversion function template
@ 2010-12-07 3:21 schaub-johannes at web dot de
2010-12-07 4:09 ` [Bug c++/46831] [C++0x] " schaub.johannes at googlemail dot com
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: schaub-johannes at web dot de @ 2010-12-07 3:21 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46831
Summary: Crash when it tries to do an invalid ICS with a
conversion function template
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: schaub-johannes@web.de
GCC crashes on this
struct B { };
struct D : B { };
struct A {
// [C++0x] default template argument for function template
template<typename T = void>
operator D&();
};
void f(B&);
int main() {
f(A());
}
This code clearly ill-formed by 13.3.3.1.2[over.ics.user] paragraph 3 . C.f.
13.3.3.1.4[ocer.ics.ref] paragraph 1.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/46831] [C++0x] Crash when it tries to do an invalid ICS with a conversion function template
2010-12-07 3:21 [Bug c++/46831] New: Crash when it tries to do an invalid ICS with a conversion function template schaub-johannes at web dot de
@ 2010-12-07 4:09 ` schaub.johannes at googlemail dot com
2010-12-07 10:59 ` paolo.carlini at oracle dot com
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: schaub.johannes at googlemail dot com @ 2010-12-07 4:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46831
--- Comment #1 from Johannes Schaub <schaub.johannes at googlemail dot com> 2010-12-07 04:09:25 UTC ---
-------------------------------------------------
GCC also rejects this valid code:
----------
struct A {
template<typename T = void> operator short();
template<typename T = void> operator long();
};
void f(long);
void f(int);
// this call is not ambiguous, but GCC claims it is
int main() { f(A()); }
Also, if we make the second conversion functon a non-template, GCC suddenly
accepts the code (right at it, the code is still valid).
But that indicates that GCC has internally the handling of
13.3.3[over.match.best]p1 bullet 4 and bullet 5 reversed: It first checks
whether one is a template and the other is a non-template, and only then checks
whether the return type of F1 converts better than the return type of F2.
--------------------------------------------------
We can make this to crash on valid code, too:
--------
struct B { };
struct D : B { };
struct A {
template<typename T = void> operator D&();
operator long();
};
void f(long);
void f(B&);
int main() { f(A()); }
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/46831] [C++0x] Crash when it tries to do an invalid ICS with a conversion function template
2010-12-07 3:21 [Bug c++/46831] New: Crash when it tries to do an invalid ICS with a conversion function template schaub-johannes at web dot de
2010-12-07 4:09 ` [Bug c++/46831] [C++0x] " schaub.johannes at googlemail dot com
@ 2010-12-07 10:59 ` paolo.carlini at oracle dot com
2010-12-07 11:22 ` rguenth at gcc dot gnu.org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: paolo.carlini at oracle dot com @ 2010-12-07 10:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46831
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org
--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2010-12-07 10:59:16 UTC ---
Let's add Jason in CC.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/46831] [C++0x] Crash when it tries to do an invalid ICS with a conversion function template
2010-12-07 3:21 [Bug c++/46831] New: Crash when it tries to do an invalid ICS with a conversion function template schaub-johannes at web dot de
2010-12-07 4:09 ` [Bug c++/46831] [C++0x] " schaub.johannes at googlemail dot com
2010-12-07 10:59 ` paolo.carlini at oracle dot com
@ 2010-12-07 11:22 ` rguenth at gcc dot gnu.org
2010-12-07 15:37 ` redi at gcc dot gnu.org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2010-12-07 11:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46831
--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2010-12-07 11:22:40 UTC ---
Would be nice to have separate bugs for the separate issues ... otherwise
categorizing this is difficult.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/46831] [C++0x] Crash when it tries to do an invalid ICS with a conversion function template
2010-12-07 3:21 [Bug c++/46831] New: Crash when it tries to do an invalid ICS with a conversion function template schaub-johannes at web dot de
` (2 preceding siblings ...)
2010-12-07 11:22 ` rguenth at gcc dot gnu.org
@ 2010-12-07 15:37 ` redi at gcc dot gnu.org
2010-12-27 19:48 ` [Bug c++/46831] [4.6 Regression][C++0x] " jakub at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2010-12-07 15:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46831
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-12-07 15:37:04 UTC ---
The ICEs in the first and third examples are regressions against 4.5
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/46831] [4.6 Regression][C++0x] Crash when it tries to do an invalid ICS with a conversion function template
2010-12-07 3:21 [Bug c++/46831] New: Crash when it tries to do an invalid ICS with a conversion function template schaub-johannes at web dot de
` (3 preceding siblings ...)
2010-12-07 15:37 ` redi at gcc dot gnu.org
@ 2010-12-27 19:48 ` jakub at gcc dot gnu.org
2011-01-21 9:30 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2010-12-27 19:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46831
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
Target Milestone|--- |4.6.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/46831] [4.6 Regression][C++0x] Crash when it tries to do an invalid ICS with a conversion function template
2010-12-07 3:21 [Bug c++/46831] New: Crash when it tries to do an invalid ICS with a conversion function template schaub-johannes at web dot de
` (4 preceding siblings ...)
2010-12-27 19:48 ` [Bug c++/46831] [4.6 Regression][C++0x] " jakub at gcc dot gnu.org
@ 2011-01-21 9:30 ` jakub at gcc dot gnu.org
2011-01-27 13:25 ` hjl.tools at gmail dot com
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-01-21 9:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46831
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/46831] [4.6 Regression][C++0x] Crash when it tries to do an invalid ICS with a conversion function template
2010-12-07 3:21 [Bug c++/46831] New: Crash when it tries to do an invalid ICS with a conversion function template schaub-johannes at web dot de
` (5 preceding siblings ...)
2011-01-21 9:30 ` jakub at gcc dot gnu.org
@ 2011-01-27 13:25 ` hjl.tools at gmail dot com
2011-01-27 13:42 ` hjl.tools at gmail dot com
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: hjl.tools at gmail dot com @ 2011-01-27 13:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46831
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011.01.27 13:07:21
Ever Confirmed|0 |1
--- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> 2011-01-27 13:07:21 UTC ---
(In reply to comment #0)
> GCC crashes on this
>
> struct B { };
> struct D : B { };
>
> struct A {
> // [C++0x] default template argument for function template
> template<typename T = void>
> operator D&();
> };
>
> void f(B&);
>
> int main() {
> f(A());
> }
>
> This code clearly ill-formed by 13.3.3.1.2[over.ics.user] paragraph 3 . C.f.
> 13.3.3.1.4[ocer.ics.ref] paragraph 1.
This ICE is caused by revision 159335:
http://gcc.gnu.org/ml/gcc-cvs/2010-05/msg00387.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/46831] [4.6 Regression][C++0x] Crash when it tries to do an invalid ICS with a conversion function template
2010-12-07 3:21 [Bug c++/46831] New: Crash when it tries to do an invalid ICS with a conversion function template schaub-johannes at web dot de
` (6 preceding siblings ...)
2011-01-27 13:25 ` hjl.tools at gmail dot com
@ 2011-01-27 13:42 ` hjl.tools at gmail dot com
2011-02-21 0:11 ` jason at gcc dot gnu.org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: hjl.tools at gmail dot com @ 2011-01-27 13:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46831
--- Comment #6 from H.J. Lu <hjl.tools at gmail dot com> 2011-01-27 13:09:52 UTC ---
(In reply to comment #1)
>
> --------------------------------------------------
> We can make this to crash on valid code, too:
> --------
>
> struct B { };
> struct D : B { };
> struct A {
> template<typename T = void> operator D&();
> operator long();
> };
>
> void f(long);
> void f(B&);
>
> int main() { f(A()); }
This ICE is also caused by revision 159335:
http://gcc.gnu.org/ml/gcc-cvs/2010-05/msg00387.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/46831] [4.6 Regression][C++0x] Crash when it tries to do an invalid ICS with a conversion function template
2010-12-07 3:21 [Bug c++/46831] New: Crash when it tries to do an invalid ICS with a conversion function template schaub-johannes at web dot de
` (7 preceding siblings ...)
2011-01-27 13:42 ` hjl.tools at gmail dot com
@ 2011-02-21 0:11 ` jason at gcc dot gnu.org
2011-02-21 2:12 ` jason at gcc dot gnu.org
2011-02-21 17:24 ` paolo.carlini at oracle dot com
10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2011-02-21 0:11 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46831
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> 2011-02-20 23:26:03 UTC ---
Got it.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/46831] [4.6 Regression][C++0x] Crash when it tries to do an invalid ICS with a conversion function template
2010-12-07 3:21 [Bug c++/46831] New: Crash when it tries to do an invalid ICS with a conversion function template schaub-johannes at web dot de
` (8 preceding siblings ...)
2011-02-21 0:11 ` jason at gcc dot gnu.org
@ 2011-02-21 2:12 ` jason at gcc dot gnu.org
2011-02-21 17:24 ` paolo.carlini at oracle dot com
10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2011-02-21 2:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46831
--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> 2011-02-21 01:50:44 UTC ---
Author: jason
Date: Mon Feb 21 01:50:39 2011
New Revision: 170354
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170354
Log:
PR c++/46831
* call.c (convert_class_to_reference): Don't try to set up a
second conv sequence for non-viable candidates.
Added:
trunk/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg2.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/call.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/46831] [4.6 Regression][C++0x] Crash when it tries to do an invalid ICS with a conversion function template
2010-12-07 3:21 [Bug c++/46831] New: Crash when it tries to do an invalid ICS with a conversion function template schaub-johannes at web dot de
` (9 preceding siblings ...)
2011-02-21 2:12 ` jason at gcc dot gnu.org
@ 2011-02-21 17:24 ` paolo.carlini at oracle dot com
10 siblings, 0 replies; 12+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-02-21 17:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46831
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #9 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-02-21 17:20:53 UTC ---
Fixed.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2011-02-21 17:21 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-07 3:21 [Bug c++/46831] New: Crash when it tries to do an invalid ICS with a conversion function template schaub-johannes at web dot de
2010-12-07 4:09 ` [Bug c++/46831] [C++0x] " schaub.johannes at googlemail dot com
2010-12-07 10:59 ` paolo.carlini at oracle dot com
2010-12-07 11:22 ` rguenth at gcc dot gnu.org
2010-12-07 15:37 ` redi at gcc dot gnu.org
2010-12-27 19:48 ` [Bug c++/46831] [4.6 Regression][C++0x] " jakub at gcc dot gnu.org
2011-01-21 9:30 ` jakub at gcc dot gnu.org
2011-01-27 13:25 ` hjl.tools at gmail dot com
2011-01-27 13:42 ` hjl.tools at gmail dot com
2011-02-21 0:11 ` jason at gcc dot gnu.org
2011-02-21 2:12 ` jason at gcc dot gnu.org
2011-02-21 17:24 ` paolo.carlini at oracle dot com
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).