g++ -O2 creates a bug by optimising: printf("%s\n", foo) -> puts(foo) > g++ -O2 > LC_ALL=moo ./xclannad segfault in puts() > g++ -O0 > LC_ALL=moo ./xclannad (null) Adding another bit of text (eg "Locale: ") stops this optimisation --- /home/shish/src/key/clean/xclannad/xlovesys.cc 2005-04-14 04:39:10.547563680 +0100 +++ /home/shish/src/key/shish/xclannad/xlovesys.cc 2005-04-14 05:41:06.560643824 +0100 @@ -4,8 +4,6 @@ /* kochi-mincho-subst.ttf あるいは -*-*-*-r-*--24-*-*-*-*-*-jisx0208.1983-* など */ /* TrueType Font は /usr/X11R6/lib/X11/fonts/TrueType/ などに存在する必要がある */ -extern void SetFont(const char* font); - #include #include #include @@ -77,7 +75,13 @@ } if(end == 1) return 0; - printf("%s\n",setlocale(LC_ALL,"")); + printf("Settings:\n"); + printf(" Locale : %s\n", setlocale(LC_ALL, "")); + printf(" Root Path : %s\n", rootPath); + printf(" Font : %s\n", font); + printf(" CD-ROM : %s\n", cdromDevice); + printf("\n"); + file_searcher.InitRoot(rootPath); config.LoadInitFile();