https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61144

--- Comment #24 from Rich Felker <bugdal at aerifal dot cx> ---
On Wed, Jul 02, 2014 at 12:22:40PM +0000, patrick at parcs dot ath.cx wrote:
> It looks like this bug has been recently fixed in the trunk (no testsuite
> addition however).  I'm not sure what its status is on the release branches,
> though.

Per discussion on gcc-patches, the issue for this exact test case went
away due to related changes not explicitly aimed at fixing this bug.
However, if dummy is const-qualified, the bug supposedly remains. I
have not yet tested with trunk to confirm this; I can do that if
necessary.

Here is the new test case:

static const int dummy = 0;
extern const int foo __attribute__((__weak__, __alias__("dummy")));
int bar() { if (foo) return 1; return 0; }

Even with the const qualifier on both dummy and foo, foo should not be
considered for constant folding because it's replaceable by alternate
definitions which may provide different values.

Reply via email to