c++/443: Enabling optimization causes a link failure
sedwards@alumni.caltech.edu
sedwards@alumni.caltech.edu
Thu Aug 3 14:46:00 GMT 2000
>Number: 443
>Category: c++
>Synopsis: Enabling optimization causes a link failure
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Thu Aug 03 14:46:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: sedwards@alumni.caltech.edu
>Release: unknown-1.0
>Organization:
>Environment:
Observed under egcs-2.91.66 on i386-redhat-linux and
under 2.95.2 on sparc-SUN-SOLARIS2.5.1
>Description:
Small program (a single file, attached) compiles and
links correctly without -O flag, but fails to link
(unresolved symbol) with -O option. Optimizer appears
to prevent code for a virtual function defined within
a class within a method from being generated.
% /bar/gcc-2.95.2/bin/g++ -O g++bug.cxx
Undefined first referenced
symbol in file
bar__Q33Baz9q__3Baz.0_3BarRi.9 /var/tmp/ccf8wr87.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
% /bar/gcc-2.95.2/bin/g++ g++bug.cxx
% # Successful
>How-To-Repeat:
Try to compile this program with -O flag. Linking should
fail.
>Fix:
Moving definition of class Bar outside scope of Baz::q()
makes it compile, but this should not be necessary.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/x-unknown-content-type-cppfile; name="g++bug.cxx"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="g++bug.cxx"
Ly8gTGluayBlcnJvcnMgd2l0aCBnKysgLU8sIGZpbmUgd2l0aCBnKysKCnN0cnVjdCBGb28gewog
IHZpcnR1YWwgdm9pZCBiYXIoaW50JiApOwogIHZpcnR1YWwgdm9pZCBiYXIoY2hhciYgKTsKfTsK
CnZvaWQgRm9vOjpiYXIoaW50JiBpKQp7CiAgaSsrOwp9Cgp2b2lkIEZvbzo6YmFyKGNoYXImIGMp
CnsKICBjKys7Cn0KCnN0cnVjdCBCYXogewogIHZvaWQgcSgpOwp9OwoKdm9pZCBCYXo6OnEoKQp7
CiAgY2xhc3MgQmFyIDogcHVibGljIEZvbyB7CiAgcHVibGljOgkKICAgIHZvaWQgYmFyKGludCZq
ICkgeyBqICs9IDI7IH0gLy8gTGluayBmYWlscyB0byBmaW5kIHRoaXMgZnVuY3Rpb24KICB9OwoK
ICBCYXIgYjsKICBpbnQgazsKICBrID0gMDsKICBiLmJhcihrKTsgICAKfQoKbWFpbigpCnsKICBC
YXogYjsKICBiLnEoKTsKfQo=
More information about the Gcc-prs
mailing list