To my best knowledge, the \xNN escape sequence
should expect exactly two hexadecimal digits, but
the following program shows that GCC is too greedy:


#include <stdio.h>

int main() {

    static const char t[] = "\x05Data";

    for(int i = 0; i != sizeof(t); ++i) {

        fprintf(stderr, "%02x ", (unsigned) t[i]);
    }

    fprintf(stderr, "\n");
}

produces:

ffffffda 74 61 00

instead of:

05 44 61 74 61 00

i.e. the "Da" from "Data" is also used as a part of the hexadecimal escape
sequence.


-- 
           Summary: Escape sequence parsing is broken
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: piotr dot wyderski at gmail dot com
  GCC host triplet: Cygwin/GCC-4.5-20090601


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42459

Reply via email to