On 07/22/2014 07:17 PM, Alexander Monakov wrote:
On Tue, 22 Jul 2014, Alexander Monakov wrote:
I'd like to push this topic forward a bit. I've bootstrapped and regtested a
version of the patch based on the initial proposal to check DECL_WEAK. The
approach with decl_replaceable_p looks not that easy; I'll expand in a
followup email.
The problem with the patch below using decl_replaceable_p is that it regresses
the following C++ testcase:
struct z {
static const int aaa = 1;
};
//const int z::aaa;
int foo(int x)
{
return x ? z::aaa : x;
}
Here decl_replaceable_p is 'true' for z::aaa. With the patch the reference to
z::aaa is not folded, but its definition is not emitted either, so a undefined
reference error is produced at link time.
Technically, this is not a bug (for C++03 at least). But I do think
folding the constant is an important optimization.
--
Florian Weimer / Red Hat Product Security