I
Ivan Shmakov
Somehow, I assumed that the following two definitions are
equivalent:
unsigned char buf[]
= ("\x1337\xcafe");
unsigned char buf[]
= ("\x13" "37\xca" "\xfe");
However, it turns out that \x1337 is understood as 0x1337, which
is then truncated to the size of unsigned char: 0x37. Thus, the
compiler reads the first definition as:
unsigned char buf[]
= ("\x37\xfe");
I wonder what do the specifications say on this matter?
TIA.
$ gcc --version
gcc (Debian 4.7.2-4) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$
equivalent:
unsigned char buf[]
= ("\x1337\xcafe");
unsigned char buf[]
= ("\x13" "37\xca" "\xfe");
However, it turns out that \x1337 is understood as 0x1337, which
is then truncated to the size of unsigned char: 0x37. Thus, the
compiler reads the first definition as:
unsigned char buf[]
= ("\x37\xfe");
I wonder what do the specifications say on this matter?
TIA.
$ gcc --version
gcc (Debian 4.7.2-4) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$