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

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