This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Warn when returning the address of a temporary (middle-end)
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: Marc Glisse <marc dot glisse at inria dot fr>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 07 Apr 2014 12:22:03 +0200
- Subject: Re: Warn when returning the address of a temporary (middle-end)
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 02 dot 1404051508500 dot 22861 at stedding dot saclay dot inria dot fr>
> One hard part is avoiding duplicate warnings. Replacing the address with 0
> is a convenient way to do that, so I did it both for my new warning and
> for the existing C/C++ ones. The patch breaks
> gfortran.dg/warn_target_lifetime_2.f90 because it ends up warning twice. I
> didn't touch that front-end because I don't know fortran, and the warning
> message "Pointer at .1. in pointer assignment might outlive the pointer
> target" doesn't seem very confident that the thing really is broken enough
> to be replaced by 0. I only tested (bootstrap+regression) the default
> languages, so ada/go may have a similar issue, to be handled if the
> approach seems ok.
Ada is designed to make such a thing impossible (although you can work around
the design with kludges like 'Unrestricted_Access) so the compiler will stop.
--
Eric Botcazou