public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/33501]  New: Copy constructor assumed to exist for undefined class
@ 2007-09-19 17:47 ciobi at inbox dot com
  2007-09-20  3:35 ` [Bug c++/33501] " bangerth at dealii dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: ciobi at inbox dot com @ 2007-09-19 17:47 UTC (permalink / raw)
  To: gcc-bugs

GCC 4.2.1 assumes that undefined classes have public copy constructors (at
least when they are used in template classes), as evidenced in the code below.
GCC 4.1.0 generates a compiler error for the same code.

-------------------- begin gcc_error2.cpp ------------------------

class A;

template <typename T>
struct X
{
    static int f(T);
    static const T& make();
    static const bool value = sizeof(f(make())) == sizeof(int);
};

int main()
{
    return X<A>::value;
}


--------------------- end gcc_error2.cpp -------------------------

================================================================

Command line:

g++ -v -save-temps gcc_error2.cpp

Using built-in specs.
Target: x86_64-suse-linux
Configured with: ../configure --enable-threads=posix --prefix=/usr
--with-local-prefix=/usr/local --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,java,ada
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.2.1
--enable-ssp --disable-libssp --disable-libgcj --with-slibdir=/lib64
--with-system-zlib --enable-shared --enable-__cxa_atexit
--enable-libstdcxx-allocator=new --disable-libstdcxx-pch --program-suffix=-4.2
--enable-version-specific-runtime-libs --without-system-libunwind
--with-cpu=generic --host=x86_64-suse-linux
Thread model: posix
gcc version 4.2.1 (SUSE Linux)
 /usr/lib64/gcc/x86_64-suse-linux/4.2.1/cc1plus -E -quiet -v -D_GNU_SOURCE
gcc_error2.cpp -mtune=generic -fpch-preprocess -o gcc_error2.ii
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/4.2.1
 /usr/include/c++/4.2.1/x86_64-suse-linux
 /usr/include/c++/4.2.1/backward
 /usr/local/include
 /usr/lib64/gcc/x86_64-suse-linux/4.2.1/include
 /usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../x86_64-suse-linux/include
 /usr/include
End of search list.
 /usr/lib64/gcc/x86_64-suse-linux/4.2.1/cc1plus -fpreprocessed gcc_error2.ii
-quiet -dumpbase gcc_error2.cpp -mtune=generic -auxbase gcc_error2 -version -o
gcc_error2.s
GNU C++ version 4.2.1 (SUSE Linux) (x86_64-suse-linux)
        compiled by GNU C version 4.2.1 (SUSE Linux).
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=128517
Compiler executable checksum: c51aed1e29693425775d4f74be6f0e18
 /usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../x86_64-suse-linux/bin/as -V
-Qy -o gcc_error2.o gcc_error2.s
GNU assembler version 2.17.50.0.5 (x86_64-suse-linux) using BFD version
2.17.50.0.5 20060927 (SUSE Linux)
 /usr/lib64/gcc/x86_64-suse-linux/4.2.1/collect2 --eh-frame-hdr -m elf_x86_64
-dynamic-linker /lib64/ld-linux-x86-64.so.2
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib64/crt1.o
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib64/crti.o
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/crtbegin.o
-L/usr/lib64/gcc/x86_64-suse-linux/4.2.1
-L/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib64 -L/lib/../lib64
-L/usr/lib/../lib64
-L/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../x86_64-suse-linux/lib
-L/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../.. gcc_error2.o -lstdc++ -lm
-lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib64/gcc/x86_64-suse-linux/4.2.1/crtend.o
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib64/crtn.o

================================================================

The preprocessed source (although in this particular case I don't see any use
for it):

-------------------- begin gcc_error2.ii -------------------------

# 1 "gcc_error2.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "gcc_error2.cpp"
class A;

template <typename T>
struct X
{
    static int f(T);
    static const T& make();
    static const bool value = sizeof(f(make())) == sizeof(int);
};

int main()
{
    return X<A>::value;
}

--------------------- end gcc_error2.ii --------------------------

================================================================


I tested this on OpenSUSE 10.2 but I'm pretty sure it's not OS-dependent. I
became aware of this issue as a result of a post by Nicola Musatti in
"comp.lang.c++.moderated" on 2007-09-06, called "Is this valid code?" (
http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/56c346896185e23e
). The code in gcc_error2.cpp is a simplified version of that presented there.
The last post as of 2007-09-17 is by Daveed Vandevoorde and I think it implies
that this is a bug in GCC 4.2.1.

================================================================

(Sorry if the format is not appropriate. I tried to follow the guidelines at
http://gcc.gnu.org/bugs.html and
http://gcc.gnu.org/bugzilla/page.cgi?id=bug-writing.html, but they seem to be
out of synch with the actual web form used for adding bug reports, which
doesn't seem to provide any place besides the "description" field to enter the
compiler output or the preprocessed file.)


-- 
           Summary: Copy constructor assumed to exist for undefined class
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ciobi at inbox dot com
 GCC build triplet: x86_64-suse-linux
  GCC host triplet: x86_64-suse-linux
GCC target triplet: x86_64-suse-linux


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


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

* [Bug c++/33501] Copy constructor assumed to exist for undefined class
  2007-09-19 17:47 [Bug c++/33501] New: Copy constructor assumed to exist for undefined class ciobi at inbox dot com
@ 2007-09-20  3:35 ` bangerth at dealii dot org
  2007-09-26 19:07 ` [Bug c++/33501] [4.1/4.2/4.3 regression] " pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bangerth at dealii dot org @ 2007-09-20  3:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from bangerth at dealii dot org  2007-09-20 03:35 -------
Confirmed. We use to error out but don't do any more with gcc4.1.2. icc
does produce an error, but Sun Studio doesn't (though I have other beef
with that latter compiler as well...)

W.


-- 

bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bangerth at dealii dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-09-20 03:35:21
               date|                            |


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


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

* [Bug c++/33501] [4.1/4.2/4.3 regression] Copy constructor assumed to exist for undefined class
  2007-09-19 17:47 [Bug c++/33501] New: Copy constructor assumed to exist for undefined class ciobi at inbox dot com
  2007-09-20  3:35 ` [Bug c++/33501] " bangerth at dealii dot org
@ 2007-09-26 19:07 ` pinskia at gcc dot gnu dot org
  2007-09-27  9:41 ` jakub at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-09-26 19:07 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.1.3


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


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

* [Bug c++/33501] [4.1/4.2/4.3 regression] Copy constructor assumed to exist for undefined class
  2007-09-19 17:47 [Bug c++/33501] New: Copy constructor assumed to exist for undefined class ciobi at inbox dot com
  2007-09-20  3:35 ` [Bug c++/33501] " bangerth at dealii dot org
  2007-09-26 19:07 ` [Bug c++/33501] [4.1/4.2/4.3 regression] " pinskia at gcc dot gnu dot org
@ 2007-09-27  9:41 ` jakub at gcc dot gnu dot org
  2007-09-28  4:12 ` mmitchel at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-09-27  9:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jakub at gcc dot gnu dot org  2007-09-27 09:41 -------
Most probably introduced by
http://gcc.gnu.org/ml/gcc-patches/2004-07/msg00902.html


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nathan at gcc dot gnu dot
                   |                            |org


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


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

* [Bug c++/33501] [4.1/4.2/4.3 regression] Copy constructor assumed to exist for undefined class
  2007-09-19 17:47 [Bug c++/33501] New: Copy constructor assumed to exist for undefined class ciobi at inbox dot com
                   ` (2 preceding siblings ...)
  2007-09-27  9:41 ` jakub at gcc dot gnu dot org
@ 2007-09-28  4:12 ` mmitchel at gcc dot gnu dot org
  2007-11-06 19:41 ` jakub at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-09-28  4:12 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


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


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

* [Bug c++/33501] [4.1/4.2/4.3 regression] Copy constructor assumed to exist for undefined class
  2007-09-19 17:47 [Bug c++/33501] New: Copy constructor assumed to exist for undefined class ciobi at inbox dot com
                   ` (3 preceding siblings ...)
  2007-09-28  4:12 ` mmitchel at gcc dot gnu dot org
@ 2007-11-06 19:41 ` jakub at gcc dot gnu dot org
  2007-11-07 19:27 ` jakub at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-11-06 19:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jakub at gcc dot gnu dot org  2007-11-06 19:41 -------
Actually caused by PR23372 fix.  Testing a fix.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jakub at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2007-09-20 03:35:21         |2007-11-06 19:41:02
               date|                            |


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


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

* [Bug c++/33501] [4.1/4.2/4.3 regression] Copy constructor assumed to exist for undefined class
  2007-09-19 17:47 [Bug c++/33501] New: Copy constructor assumed to exist for undefined class ciobi at inbox dot com
                   ` (4 preceding siblings ...)
  2007-11-06 19:41 ` jakub at gcc dot gnu dot org
@ 2007-11-07 19:27 ` jakub at gcc dot gnu dot org
  2007-11-07 19:29 ` [Bug c++/33501] [4.1/4.2 " jakub at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-11-07 19:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jakub at gcc dot gnu dot org  2007-11-07 19:27 -------
Subject: Bug 33501

Author: jakub
Date: Wed Nov  7 19:27:27 2007
New Revision: 129968

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129968
Log:
        PR c++/33501
        * call.c (build_over_call): Don't check TREE_ADDRESSABLE
        on incomplete type.

        * g++.dg/warn/incomplete2.C: New test.
        * g++.dg/template/incomplete4.C: New test.
        * g++.dg/template/incomplete5.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/template/incomplete4.C
    trunk/gcc/testsuite/g++.dg/template/incomplete5.C
    trunk/gcc/testsuite/g++.dg/warn/incomplete2.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/33501] [4.1/4.2 regression] Copy constructor assumed to exist for undefined class
  2007-09-19 17:47 [Bug c++/33501] New: Copy constructor assumed to exist for undefined class ciobi at inbox dot com
                   ` (5 preceding siblings ...)
  2007-11-07 19:27 ` jakub at gcc dot gnu dot org
@ 2007-11-07 19:29 ` jakub at gcc dot gnu dot org
  2007-11-12 19:50 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-11-07 19:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jakub at gcc dot gnu dot org  2007-11-07 19:29 -------
Fixed on the trunk so far.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|4.0.4                       |4.0.4 4.3.0
            Summary|[4.1/4.2/4.3 regression]    |[4.1/4.2 regression] Copy
                   |Copy constructor assumed to |constructor assumed to exist
                   |exist for undefined class   |for undefined class


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


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

* [Bug c++/33501] [4.1/4.2 regression] Copy constructor assumed to exist for undefined class
  2007-09-19 17:47 [Bug c++/33501] New: Copy constructor assumed to exist for undefined class ciobi at inbox dot com
                   ` (6 preceding siblings ...)
  2007-11-07 19:29 ` [Bug c++/33501] [4.1/4.2 " jakub at gcc dot gnu dot org
@ 2007-11-12 19:50 ` pinskia at gcc dot gnu dot org
  2008-07-04 22:18 ` [Bug c++/33501] [4.2 " jsm28 at gcc dot gnu dot org
  2009-03-30 22:20 ` jsm28 at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-11-12 19:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2007-11-12 19:50 -------
*** Bug 33975 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrew dot stubbs at st dot
                   |                            |com


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


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

* [Bug c++/33501] [4.2 regression] Copy constructor assumed to exist for undefined class
  2007-09-19 17:47 [Bug c++/33501] New: Copy constructor assumed to exist for undefined class ciobi at inbox dot com
                   ` (7 preceding siblings ...)
  2007-11-12 19:50 ` pinskia at gcc dot gnu dot org
@ 2008-07-04 22:18 ` jsm28 at gcc dot gnu dot org
  2009-03-30 22:20 ` jsm28 at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-07-04 22:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jsm28 at gcc dot gnu dot org  2008-07-04 22:17 -------
Closing 4.1 branch.


-- 

jsm28 at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.1/4.2 regression] Copy   |[4.2 regression] Copy
                   |constructor assumed to exist|constructor assumed to exist
                   |for undefined class         |for undefined class
   Target Milestone|4.1.3                       |4.2.5


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


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

* [Bug c++/33501] [4.2 regression] Copy constructor assumed to exist for undefined class
  2007-09-19 17:47 [Bug c++/33501] New: Copy constructor assumed to exist for undefined class ciobi at inbox dot com
                   ` (8 preceding siblings ...)
  2008-07-04 22:18 ` [Bug c++/33501] [4.2 " jsm28 at gcc dot gnu dot org
@ 2009-03-30 22:20 ` jsm28 at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-30 22:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jsm28 at gcc dot gnu dot org  2009-03-30 22:19 -------
Closing 4.2 branch, fixed in 4.3.


-- 

jsm28 at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Known to fail|4.1.2 4.2.0                 |4.1.2 4.2.0 4.2.5
         Resolution|                            |FIXED
   Target Milestone|4.2.5                       |4.3.0


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


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

end of thread, other threads:[~2009-03-30 22:20 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-19 17:47 [Bug c++/33501] New: Copy constructor assumed to exist for undefined class ciobi at inbox dot com
2007-09-20  3:35 ` [Bug c++/33501] " bangerth at dealii dot org
2007-09-26 19:07 ` [Bug c++/33501] [4.1/4.2/4.3 regression] " pinskia at gcc dot gnu dot org
2007-09-27  9:41 ` jakub at gcc dot gnu dot org
2007-09-28  4:12 ` mmitchel at gcc dot gnu dot org
2007-11-06 19:41 ` jakub at gcc dot gnu dot org
2007-11-07 19:27 ` jakub at gcc dot gnu dot org
2007-11-07 19:29 ` [Bug c++/33501] [4.1/4.2 " jakub at gcc dot gnu dot org
2007-11-12 19:50 ` pinskia at gcc dot gnu dot org
2008-07-04 22:18 ` [Bug c++/33501] [4.2 " jsm28 at gcc dot gnu dot org
2009-03-30 22:20 ` jsm28 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).