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] Warn on and fold NULL checks against inline functions

On Mon, 26 May 2014, Patrick Palka wrote:

On Mon, May 26, 2014 at 4:26 PM, Marc Glisse <> wrote:
On Mon, 26 May 2014, Patrick Palka wrote:

This patch teaches the C++ frontend to warn on NULL checks against
inline functions and it teaches the middle-end to fold NULL checks
against inline functions.  These two things are currently done for
non-inline C++ functions, but inline functions are exceptional in that
the C++ frontend marks them as weak, and NULL checks against weak
symbols cannot be folded in general because the symbol may be mapped to
NULL at link-time.

But in the case of an inline function, the fact that it's a weak symbol
is an implementation detail.  And because it is not permitted to
explicitly give an inline function the "weak" attribute (see
handle_weak_attribute), in order to acheive $SUBJECT it suffices to
assume that all inline functions are non-null, which is what this patch

Thanks for working on this. You may want to mention PR 59948 in the
ChangeLog. In the comments of that PR, Honza seems to have a different idea
of what the fold-const test should look like.

I wonder, then, if the test in c-common.c is also broken...  Thanks
for the heads up about the PR.

I think I should also mention PR 61144 which says the test can be wrong in the other direction (I didn't look at it closely).

But even if the tests are broken, your patch may still be an improvement while waiting for the rewrite...

Marc Glisse

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