> > Are the attached files acceptable? The testcase looks OK to me, but it already should be fixed on mainline by patch https://gcc.gnu.org/ml/gcc-patches/2014-05/msg01315.html that prevents dummy to be marked as constant.
You can however modify the testcase to have __attribute__ ((weak)) const int foo=0; This needs your decl_replaceable change to not be optimized to if (0), because of the explicit const modifier. I did not change ctor_for_folding to reject variables above as I was not quite sure we want to support this kind of interposition and I am still not quite certain. C++ is quite clear about the transformation replacing initialized const by its value. Honza > > Rich > /* { dg-do run } */ > /* { dg-require-weak "" } */ > /* { dg-require-alias "" } */ > /* { dg-additional-sources "wkali-3a.c" } */ > > #include <stdlib.h> > > static int dummy = 0; > extern int foo __attribute__((__weak__, __alias__("dummy"))); > > int main(void) { > > if (foo) > exit(0); > else > abort(); > } > /* { dg-do run } */ > > int foo = 1;