This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] proposed fix for bug # 61144

On Wed, May 21, 2014 at 11:17:53AM +0200, Richard Biener wrote:
> On Wed, May 21, 2014 at 3:59 AM, Rich Felker <> wrote:
> > Bug # 61144 is a regression in 4.9.0 that breaks building of musl libc
> > due to aggressive and semantically-incorrect constant folding of weak
> > aliases. The attached patch seems to fix the issue. A weak alias
> > should never be a candidate for constant folding because it may always
> > be replaced by a strong definition from another translation unit.
> >
> > For details see
> >
> > I do not have a copyright assignment on file but this patch should be
> > sufficiently trivial not to require it.
> Please add a testcase.  Also I wonder why it isn't better to generalize

How should a testcase be done? On the PR there's a testcase that shows
the problem in the generated code, but no automated check for it.
Testing this is actually a bit of a pain unless you're allowed to run
the generated program.

>   /* Variables declared 'const' without an initializer
>      have zero as the initializer if they may not be
>      overridden at link or run time.  */
>   if (!DECL_INITIAL (real_decl)
>       && (DECL_EXTERNAL (decl) || decl_replaceable_p (decl)))
>     return error_mark_node;
> Honza?

Indeed, this may be a better place to do it as long as
decl_replaceable_p reliably returns true for weak aliases. If so, the
following might work:

   if ((!DECL_INITIAL (real_decl) && DECL_EXTERNAL (decl))
       || decl_replaceable_p (decl)))
     return error_mark_node;

On the other hand, I might just separate it out into two separate if
statements since they should probably have their own comments.

I would appreciate help from anyone familiar with GCC internals on
getting this right.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]