public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/34824]  New: ICE with explicit copy constructor
@ 2008-01-17  6:42 kristian dot spangsege at gmail dot com
  2008-01-17  9:34 ` [Bug c++/34824] " kristian dot spangsege at gmail dot com
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: kristian dot spangsege at gmail dot com @ 2008-01-17  6:42 UTC (permalink / raw)
  To: gcc-bugs

The following small test case causes GCC to ICE:

struct A;

struct B
{
  B(A const &);
  explicit B(B const &);
};

struct A
{
  A(B) {}
};

B f(A const &a) { return B(a); }


Same result (ICE) on the following two systems:

gcc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
gcc (GCC) 4.1.1 20070105 (Red Hat 4.1.1-51)


If the "explicit" keyword is dropped the ICE disappears. The same is true if
the argument to A's constructor is changed to an reference.


-- 
           Summary: ICE with explicit copy constructor
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kristian dot spangsege at gmail dot com
 GCC build triplet: 4.1.2
  GCC host triplet: 4.1.2
GCC target triplet: 4.1.2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34824


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/34824] ICE with explicit copy constructor
  2008-01-17  6:42 [Bug c++/34824] New: ICE with explicit copy constructor kristian dot spangsege at gmail dot com
@ 2008-01-17  9:34 ` kristian dot spangsege at gmail dot com
  2008-01-17 12:53 ` rguenth at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: kristian dot spangsege at gmail dot com @ 2008-01-17  9:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from kristian dot spangsege at gmail dot com  2008-01-17 07:37 -------
Just tested it on the latest release 4.2.2 build from source with no patches
and the ICE is still there.

System:
g++ (GCC) 4.2.2
Linux localhost.localdomain 2.6.20-1.2952.fc6 #1 SMP Wed May 16 18:59:18 EDT
2007 i686 i686 i386 GNU/Linux
Fedora Core release 6 (Zod)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34824


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/34824] ICE with explicit copy constructor
  2008-01-17  6:42 [Bug c++/34824] New: ICE with explicit copy constructor kristian dot spangsege at gmail dot com
  2008-01-17  9:34 ` [Bug c++/34824] " kristian dot spangsege at gmail dot com
@ 2008-01-17 12:53 ` rguenth at gcc dot gnu dot org
  2008-01-20  6:50 ` [Bug c++/34824] [4.1/4.2/4.3 Regression] " pinskia at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-17 12:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2008-01-17 12:26 -------
Confirmed.  Even if it doesn't look like it makes sense to have an explicit
copy constructor, the standard does not seem to prohibit this.

But,

B f(A const &a) { return B(a); }

invokes the copy constructor for B, and thus would raise an error.

A diagnostic is missing.

Interestingly EDG ICEs as well ;)

/icpc -strict_ansi -S t.C
icpc: error: Fatal error in
/suse/rguenther/bin/opt/intel/cce/9.1.039/bin/mcpcom, terminated by
segmentation violation
compilation aborted for t.C (code 1)

2.95 wrongly accepts this code, but doesn't ICE.  So not a regression
IMHO.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |diagnostic, ice-on-invalid-
                   |                            |code
      Known to fail|                            |3.3.6 4.1.3 4.3.0
   Last reconfirmed|0000-00-00 00:00:00         |2008-01-17 12:26:53
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34824


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/34824] [4.1/4.2/4.3 Regression] ICE with explicit copy constructor
  2008-01-17  6:42 [Bug c++/34824] New: ICE with explicit copy constructor kristian dot spangsege at gmail dot com
  2008-01-17  9:34 ` [Bug c++/34824] " kristian dot spangsege at gmail dot com
  2008-01-17 12:53 ` rguenth at gcc dot gnu dot org
@ 2008-01-20  6:50 ` pinskia at gcc dot gnu dot org
  2008-01-21 20:42 ` jakub at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-01-20  6:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2008-01-20 05:38 -------
(In reply to comment #2)
> 2.95 wrongly accepts this code, but doesn't ICE.  So not a regression
> IMHO.

No it is a regression as anything (besides another ICE) to ICE is considered a
regression.    I remember we put these rules somewhere.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
            Summary|ICE with explicit copy      |[4.1/4.2/4.3 Regression] ICE
                   |constructor                 |with explicit copy
                   |                            |constructor
   Target Milestone|---                         |4.1.3


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34824


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/34824] [4.1/4.2/4.3 Regression] ICE with explicit copy constructor
  2008-01-17  6:42 [Bug c++/34824] New: ICE with explicit copy constructor kristian dot spangsege at gmail dot com
                   ` (2 preceding siblings ...)
  2008-01-20  6:50 ` [Bug c++/34824] [4.1/4.2/4.3 Regression] " pinskia at gcc dot gnu dot org
@ 2008-01-21 20:42 ` jakub at gcc dot gnu dot org
  2008-01-21 23:27 ` pcarlini at suse dot de
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-01-21 20:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jakub at gcc dot gnu dot org  2008-01-21 20:29 -------
Related testcase:
struct A;

struct B
{
  B (A const &);
  B (B &);
};

struct A
{
  A (B) {}
};

B
f (A const &a)
{
  return B (a);
}

which doesn't have explicit at all segfaults as well, also endless recursion.
In both cases the copy constructor can't be used,
so a conversion through A(B) constructor and then B(const A&) is attempted.
But that needs a temporary, so a B(const B &) copy constructor is needed and
we are back to the original problem.

If A's constructor is instead A (const B &) {}, then it compiles just fine
in both variants ( explicit B (const B &); and B (B &); ).  So I guess we just
need to detect recursion here.  I believe C++ will try only one hop through
some
other class' constructor, so perhaps just remembering one parent type would
be enough to prevent the recursion.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34824


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/34824] [4.1/4.2/4.3 Regression] ICE with explicit copy constructor
  2008-01-17  6:42 [Bug c++/34824] New: ICE with explicit copy constructor kristian dot spangsege at gmail dot com
                   ` (3 preceding siblings ...)
  2008-01-21 20:42 ` jakub at gcc dot gnu dot org
@ 2008-01-21 23:27 ` pcarlini at suse dot de
  2008-01-22 13:58 ` jakub at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pcarlini at suse dot de @ 2008-01-21 23:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pcarlini at suse dot de  2008-01-21 23:23 -------
Related to PR28475, then?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34824


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/34824] [4.1/4.2/4.3 Regression] ICE with explicit copy constructor
  2008-01-17  6:42 [Bug c++/34824] New: ICE with explicit copy constructor kristian dot spangsege at gmail dot com
                   ` (4 preceding siblings ...)
  2008-01-21 23:27 ` pcarlini at suse dot de
@ 2008-01-22 13:58 ` jakub at gcc dot gnu dot org
  2008-01-23 21:12 ` jakub at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-01-22 13:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jakub at gcc dot gnu dot org  2008-01-22 13:49 -------
Yes, probably even a dup of that.  I don't have 2.95 to verify this is a
regression.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34824


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/34824] [4.1/4.2/4.3 Regression] ICE with explicit copy constructor
  2008-01-17  6:42 [Bug c++/34824] New: ICE with explicit copy constructor kristian dot spangsege at gmail dot com
                   ` (5 preceding siblings ...)
  2008-01-22 13:58 ` jakub at gcc dot gnu dot org
@ 2008-01-23 21:12 ` jakub at gcc dot gnu dot org
  2008-01-23 22:49 ` rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-01-23 21:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jakub at gcc dot gnu dot org  2008-01-23 20:26 -------
*** Bug 28475 has been marked as a duplicate of this bug. ***


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jkherciueh at gmx dot net


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34824


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/34824] [4.1/4.2/4.3 Regression] ICE with explicit copy constructor
  2008-01-17  6:42 [Bug c++/34824] New: ICE with explicit copy constructor kristian dot spangsege at gmail dot com
                   ` (6 preceding siblings ...)
  2008-01-23 21:12 ` jakub at gcc dot gnu dot org
@ 2008-01-23 22:49 ` rguenth at gcc dot gnu dot org
  2008-01-23 23:01 ` fang at csl dot cornell dot edu
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-23 22:49 UTC (permalink / raw)
  To: gcc-bugs



-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |2.95.4
           Priority|P3                          |P2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34824


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/34824] [4.1/4.2/4.3 Regression] ICE with explicit copy constructor
  2008-01-17  6:42 [Bug c++/34824] New: ICE with explicit copy constructor kristian dot spangsege at gmail dot com
                   ` (7 preceding siblings ...)
  2008-01-23 22:49 ` rguenth at gcc dot gnu dot org
@ 2008-01-23 23:01 ` fang at csl dot cornell dot edu
  2008-02-13  3:57 ` jason at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: fang at csl dot cornell dot edu @ 2008-01-23 23:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from fang at csl dot cornell dot edu  2008-01-23 22:48 -------
As long as we're digging back...
the test case in Comment #4

also ICEs:
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)

also "works":
gcc version 2.95.3 [FreeBSD] 20010315 (release)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34824


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/34824] [4.1/4.2/4.3 Regression] ICE with explicit copy constructor
  2008-01-17  6:42 [Bug c++/34824] New: ICE with explicit copy constructor kristian dot spangsege at gmail dot com
                   ` (8 preceding siblings ...)
  2008-01-23 23:01 ` fang at csl dot cornell dot edu
@ 2008-02-13  3:57 ` jason at gcc dot gnu dot org
  2008-02-13  4:07 ` jason at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu dot org @ 2008-02-13  3:57 UTC (permalink / raw)
  To: gcc-bugs



-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jason at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2008-01-17 12:26:53         |2008-02-13 03:56:26
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34824


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/34824] [4.1/4.2/4.3 Regression] ICE with explicit copy constructor
  2008-01-17  6:42 [Bug c++/34824] New: ICE with explicit copy constructor kristian dot spangsege at gmail dot com
                   ` (9 preceding siblings ...)
  2008-02-13  3:57 ` jason at gcc dot gnu dot org
@ 2008-02-13  4:07 ` jason at gcc dot gnu dot org
  2008-02-13  5:00 ` [Bug c++/34824] [4.1/4.2 " jason at gcc dot gnu dot org
  2008-02-21 21:08 ` reichelt at gcc dot gnu dot org
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu dot org @ 2008-02-13  4:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from jason at gcc dot gnu dot org  2008-02-13 04:06 -------
Subject: Bug 34824

Author: jason
Date: Wed Feb 13 04:06:03 2008
New Revision: 132282

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132282
Log:
        PR c++/34824
        * call.c (convert_like_real): Pass LOOKUP_ONLYCONVERTING to build_temp
        if we're doing conversions to call a user-defined conversion function.

Added:
    trunk/gcc/testsuite/g++.dg/overload/copy1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34824


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/34824] [4.1/4.2 Regression] ICE with explicit copy constructor
  2008-01-17  6:42 [Bug c++/34824] New: ICE with explicit copy constructor kristian dot spangsege at gmail dot com
                   ` (10 preceding siblings ...)
  2008-02-13  4:07 ` jason at gcc dot gnu dot org
@ 2008-02-13  5:00 ` jason at gcc dot gnu dot org
  2008-02-21 21:08 ` reichelt at gcc dot gnu dot org
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu dot org @ 2008-02-13  5:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from jason at gcc dot gnu dot org  2008-02-13 05:00 -------
Fixed for 4.3.0.  Bugs on invalid code don't seem worth backporting.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Known to fail|3.3.6 4.1.3 4.3.0           |3.3.6 4.1.3
      Known to work|2.95.4                      |2.95.4 4.3.0
         Resolution|                            |FIXED
            Summary|[4.1/4.2/4.3 Regression] ICE|[4.1/4.2 Regression] ICE
                   |with explicit copy          |with explicit copy
                   |constructor                 |constructor


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34824


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/34824] [4.1/4.2 Regression] ICE with explicit copy constructor
  2008-01-17  6:42 [Bug c++/34824] New: ICE with explicit copy constructor kristian dot spangsege at gmail dot com
                   ` (11 preceding siblings ...)
  2008-02-13  5:00 ` [Bug c++/34824] [4.1/4.2 " jason at gcc dot gnu dot org
@ 2008-02-21 21:08 ` reichelt at gcc dot gnu dot org
  12 siblings, 0 replies; 14+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2008-02-21 21:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from reichelt at gcc dot gnu dot org  2008-02-21 21:07 -------
Adjust target milestone.


-- 

reichelt at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  GCC build triplet|4.1.2                       |
   GCC host triplet|4.1.2                       |
 GCC target triplet|4.1.2                       |
   Target Milestone|4.1.3                       |4.3.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34824


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2008-02-21 21:08 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-17  6:42 [Bug c++/34824] New: ICE with explicit copy constructor kristian dot spangsege at gmail dot com
2008-01-17  9:34 ` [Bug c++/34824] " kristian dot spangsege at gmail dot com
2008-01-17 12:53 ` rguenth at gcc dot gnu dot org
2008-01-20  6:50 ` [Bug c++/34824] [4.1/4.2/4.3 Regression] " pinskia at gcc dot gnu dot org
2008-01-21 20:42 ` jakub at gcc dot gnu dot org
2008-01-21 23:27 ` pcarlini at suse dot de
2008-01-22 13:58 ` jakub at gcc dot gnu dot org
2008-01-23 21:12 ` jakub at gcc dot gnu dot org
2008-01-23 22:49 ` rguenth at gcc dot gnu dot org
2008-01-23 23:01 ` fang at csl dot cornell dot edu
2008-02-13  3:57 ` jason at gcc dot gnu dot org
2008-02-13  4:07 ` jason at gcc dot gnu dot org
2008-02-13  5:00 ` [Bug c++/34824] [4.1/4.2 " jason at gcc dot gnu dot org
2008-02-21 21:08 ` reichelt at gcc dot gnu dot org

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).