Boost logo

Boost :

From: Tony Han Bao (tonybao_at_[hidden])
Date: 2005-02-10 21:23:42


Hi John,

 From the standard:

9.4.2 Static data members

4 If a static data member is of const integral or const enumeration
type, its declaration in the class definition can specify a
constant-initializer which shall be an integral constant expression
(5.19). In that case, the member can appear in integral constant
expressions within its scope. The member shall still be defined in a
namespace scope if it is used in the program and the namespace scope
definition shall not contain an initializer.

so adding the line

        const short S::l1;

solves the problem.

But I still don't understand neither why passing by value doesn't cause
the error.

On 11 Feb 2005, at 01:03, John Eddy wrote:

> The following bit of code gives me an undefined symbol (l1) when using
> gcc 3.2.2-5.8. Is there something wrong with the code or is there a
> bug in the compiler or a setting I don't know about, etc?
>
>
> struct S { static const short l1 = 10; };
>
> void go(const short& l) {}; // causes undefined symbol l1
>
> int main(int argc, char* argv[]) { go(S::l1); return 0; }
>
>
> If I do normal, non-in-class-initialization, the problem doesn't
> appear nor does it appear if I accept the short by value in go.
>
> Thanks,
> John
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
Tony Han Bao
tonybao_at_[hidden]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk