Bug 33569 - A bug in inlining static const members.
Summary: A bug in inlining static const members.
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-27 09:59 UTC by Juraj Ivančić
Modified: 2007-09-27 10:10 UTC (History)
2 users (show)

See Also:
Host: i686 i386 GNU/Linux
Target: i686 i386 GNU/Linux
Build: i686 i386 GNU/Linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Juraj Ivančić 2007-09-27 09:59:48 UTC
Linkage of the following example reports an undefined reference to `A::anInt'.

---- example.cpp
struct A
{
	template<typename T>
	void operator%( T const & object ) {}
	static int const anInt = 5;
};

int main( void )
{
	A() % A::anInt;
	return 0;
}
Comment 1 Paolo Carlini 2007-09-27 10:10:02 UTC
Indeed, in general you have to add:

const int A::anInt;

At high optimization levels the the static int is "inlined" but this is just implementation defined behavior...