This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Bug?: local class and -O1


Hi,

I'm not sure if this a bug, but g++ with -O0 accept it but fail to link
with -O1.

prog.cc:

class B
{
public:
    virtual void f() const = 0;
};

void
foo(B const &)
{

}

void
bar()
{
  class D : public B
  {
    void f() const
      {

      }
  };
 foo (D());
}

int
main() 
{
  bar();
  return 0;
}

g++ --verbose -O1 prog.cc
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/specs
gcc version 2.95.1 19990816 (release)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/cpp -lang-c++ -v
-D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -D__ELF__
-Dunix -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__
-D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -D__OPTIMIZE__
-Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di686
-Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ prog.cc
/tmp/cc1V6mke.ii
GNU CPP version 2.95.1 19990816 (release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:

/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/../../../../include/g++-3
 /usr/local/include

/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/../../../../i686-pc-linux-gnu/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/include
 /usr/include
End of search list.
The following default directories have been omitted from the search
path:
End of omitted list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/cc1plus
/tmp/cc1V6mke.ii -quiet -dumpbase prog.cc -O1 -version -o
/tmp/cc9xhG3f.s
GNU C++ version 2.95.1 19990816 (release) (i686-pc-linux-gnu) compiled
by GNU C version 2.95.1 19990816 (release).
 as -V -Qy -o /tmp/ccMLXzsi.o /tmp/cc9xhG3f.s
GNU assembler version 2.9.1 (i386-redhat-linux), using BFD version
2.9.1.0.23
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/collect2 -m elf_i386
-dynamic-linker /lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/crtbegin.o
-L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1
-L/usr/local/i686-pc-linux-gnu/lib -L/usr/local/lib /tmp/ccMLXzsi.o
-lstdc++ -lm -lgcc -lc -lgcc
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/crtend.o /usr/lib/crtn.o
/tmp/ccMLXzsi.o(.gnu.linkonce.d.__vt_Q29bar__Fv.0_1D+0x8): undefined
reference to `f__CQ29bar__Fv.0_1D.6'
collect2: ld returned 1 exit status


gcc version 2.96 20000221 (experimental) gives the same result.

Ulf

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]