[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#328119: g++-4.0: Fails to build attached code unless optimisation level > 0

Package: g++-4.0
Version: 4.0.1-6
Severity: important

This code gives fails to link unless compiled with optimisation. -O1,
-O2, -O3..., or -Os all compile fine, just -O0 bombs out with:

$ g++-4.0 buggered.cpp 
/tmp/cc25MWXo.o: In function `fp::operator>(fp const&) const':
buggered.cpp:(.gnu.linkonce.t._ZNK2fpgtERKS_[fp::operator>(fp const&) const]+0x5): undefined reference to `fp::e'
collect2: ld returned 1 exit status
$ g++-4.0 -O2 buggered.cpp 

-- snip --
class fp {
        static const double e = 0.00001;
        double val;
        fp(double val) : val(val) {}
        bool operator > (const fp& f) const { return e == 0; }

int main() {
        fp f(1), g(2);
        return f > g;
-- snip --

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.13
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages g++-4.0 depends on:
ii  gcc-4.0                       4.0.1-6    The GNU C compiler
ii  gcc-4.0-base                  4.0.1-6    The GNU Compiler Collection (base 
ii  libc6                         2.3.5-6    GNU C Library: Shared libraries an
ii  libstdc++6-4.0-dev            4.0.1-6    The GNU Standard C++ Library v3 (d

g++-4.0 recommends no packages.

-- no debconf information

Reply to: