[Bug c++/14404] New: static const integral member cannot be passed as const reference

saurik at saurik dot com gcc-bugzilla@gcc.gnu.org
Wed Mar 3 09:03:00 GMT 2004


It might be that I just don't understand the standard well enough, but I would 
have expected the following code to have worked. I'm assuming it fails because 
I'm taking a reference of a variable that I didn't explicitely instantiate 
outside the class, but considering if I replace Foo::value with the constant 
1024 it would work I seems as if this construct should be accepted as well.

void doit(const unsigned &) {}
struct Foo { static const unsigned value = 1024; };
int main() { doit(Foo::value); return 0; }

/tmp/ccmjMvPb.o(.text+0x25): In function `main':
: undefined reference to `Foo::value'
collect2: ld returned 1 exit status

-- 
           Summary: static const integral member cannot be passed as const
                    reference
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: saurik at saurik dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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



More information about the Gcc-bugs mailing list