This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Turning warning "returning reference to temporary" into error?
- From: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- To: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: gcc at gcc dot gnu dot org
- Date: Sun, 11 May 2003 21:47:46 +0200 (CEST)
- Subject: Re: Turning warning "returning reference to temporary" into error?
On 11 May 2003, Gabriel Dos Reis wrote:
> Richard Guenther <rguenth@tat.physik.uni-tuebingen.de> writes:
>
> | On 11 May 2003, Gabriel Dos Reis wrote:
> |
> | > Richard Guenther <rguenth@tat.physik.uni-tuebingen.de> writes:
> | >
> | > [...]
> | >
> | > | Wouldnt it be a good idea to at least turn the
> | > | maybe_warn_about_returning_address_of_local warnings into an error with
> | > | -pedantic? Or always?
> | >
> | > This is not always practical since the actual meaning (i.e. error or
> | > not) depends on the code path during runtime.
> |
> | Hm - I cannot think of any "legal" use, other than ignoring the return
> | value, of course.
>
> A compiler writer cannot imagine every possible usage. Which is why
> somethings are warnings. In this case, if the return value is ignored
> then the program is valid. GCC cannot reject it just because
> -pedantic is specified.
What about giving the warning a name, -Wreturn f.e., so I can use
-w -Wreturn -Werror to turn it into an error?
Richard.