This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/31870] Failure to diagnose taking address of register variable
- From: "neil at daikokuya dot co dot uk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 May 2007 22:39:28 -0000
- Subject: [Bug c/31870] Failure to diagnose taking address of register variable
- References: <bug-31870-6@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from neil at daikokuya dot co dot uk 2007-05-09 23:39 -------
Subject: Re: Failure to diagnose taking address of register variable
bangerth at dealii dot org wrote:-
> Uh, can you elaborate? We get the warning you want if we have
> int d (void) { register int a[2]; return a; }
> instead. In your case, i.e. "return a,1", we return 1, but we still
> need evaluate the expression "a". I assume that you mean that this
> implies that we have to do the array-to-pointer decay operation. However,
Yes, it has to be done.
> for that case, C99's clause 6.3.2.1/3 says that that's possible for
> register storage class arrays but that the result is undefined.
Right. GCC seems to want to diagnose this undefined behaviour; it
does in all other circumstances.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31870