This is the mail archive of the
mailing list for the GCC project.
Re: Warn when returning the address of a temporary (middle-end) v2
- From: Marc Glisse <marc dot glisse at inria dot fr>
- To: Richard Sandiford <rdsandiford at googlemail dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 27 Jul 2014 20:43:21 +0200 (CEST)
- Subject: Re: Warn when returning the address of a temporary (middle-end) v2
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 02 dot 1406221930380 dot 20514 at stedding dot saclay dot inria dot fr> <87fvhmllc5 dot fsf at talisman dot default>
On Sun, 27 Jul 2014, Richard Sandiford wrote:
Marc Glisse <email@example.com> writes:
I followed the advice in this discussion:
and here is a new patch. I made an effort to isolate a path in at least
one subcase so it doesn't look too strange that the warning is in this
file. Computing the dominance info just to tweak the warning message may
be a bit excessive.
How about only calculating it once you've decided to issue a message?
Good idea! I'll post the updated patch after testing.
+ if (always_executed)
+ msg = "function returns address of local variable";
+ msg = "function may return address of local variable";
I think you need _(...) here, unless some magic makes that unnecessary now.
I just tried to see how the magic happens when someone calls error_at, and
it goes through diagnostic_set_info, which contains:
diagnostic_set_info_translated (diagnostic, _(gmsgid), args, location, kind);
So I think the _(...) is already taken care of. But I don't know that code
at all and I could easily have looked at it wrong.
Thanks for the help,