warning on valid escape sequence in C string & invalid result.
>Submitter-Id: net
>Originator: Changwoo Ryu
>Organization:
>Confidential: no
>Synopsis: warning on valid escape sequence in C string & invalid result.
>Severity: serious
>Priority: low
>Category: c
>Class: wrong-code
>Release: 3.0.4 (Debian testing/unstable)
>Environment:
System: Linux hades.idis.co.kr 2.4.17 #1 Sat Feb 2 13:06:14 KST 2002 i686 unknown
Architecture: i686
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --enable-threads=posix --enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux
>Description:
compiler outputs a warning on "Fran\xE7ais" static string and
compiled it as string "Franzis".
>How-To-Repeat:
Compile this program and run:
----------------------------------------------------------------------
#include <stdio.h>
const char *french1 = "Fran\xE7ais";
const char *french2 = "Fran" "\xE7" "ais";
int
main(int argc, char *argv[])
{
printf("%s: \"%c\", %d\n", french1, french1[4], (int)french1[4]);
printf("%s: \"%c\", %d\n", french2, french2[4], (int)french2[4]);
}
----------------------------------------------------------------------
The second string should be the same as the first one. But the
outputs are different.
>Fix:
Reply to: