This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/51862] Over optimization for assignments to char[] defined inner than used
- From: "pinskia at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 15 Jan 2012 04:46:59 +0000
- Subject: [Bug c/51862] Over optimization for assignments to char[] defined inner than used
- Auto-submitted: auto-generated
- References: <bug-51862-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51862
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-01-15 04:46:59 UTC ---
This code is undefined in that buf escapes the scope which causes the undefined
behavior.
{
char buf[4];
unsigned int ch = strtoul(++p, &pe, 16);
len = convert_UTF32_to_UTF8(buf, ch);
unescape = buf;
}
Any use of buf after the scope closes is undefined. GCC 4.7.0 optimizes better
with respect of this undefinedness.