This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/51862] Over optimization for assignments to char[] defined inner than used


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]