gcc warnings garbled `... foo.c: In function @!#'

Bug #20268 reported by Ian Jackson
6
Affects Status Importance Assigned to Milestone
gcc-4.0 (Ubuntu)
Medium
Matthias Klose

Bug Description

gcc-4.0 sometimes loses track of the function name and instead prints garbage.
I suspect that this is common-or-garden Undefined Behaviour on the part of gcc.

In my example, I was compiling gs-esp-7.07.1-9ubuntu4 with gcc-4.0
4.0.1-4ubuntu5 on whatever is in today's Breezy snapshot. I noticed the
corrupted messages scrolling past and pressed ^C. Here is an example:

./obj/echogs -e .dev -w- -l-obj ./obj/cmyklib ./obj/gscolor1.o ./obj/gsht1.o
i486-linux-gnu-gcc -DHAVE_MKSTEMP -Wall -g -O2 -I/usr/include/glib-2.0
-I/usr/lib/glib-2.0/include -Wall -Wstrict-prototypes -Wmissing-declarations
-Wmissing-prototypes -Wcast-qual -Wwrite-strings -fno-builtin -fno-common
-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\"
-DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DHAVE_DIRENT_H=1
-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1
-DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
-DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_ERRNO_H=1 -DHAVE_FCNTL_H=1
-DHAVE_LIMITS_H=1 -DHAVE_MALLOC_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STDLIB_H=1
-DHAVE_STRING_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_IOCTL_H=1 -DHAVE_SYS_PARAM_H=1
-DHAVE_SYS_TIME_H=1 -DHAVE_SYSLOG_H=1 -DHAVE_UNISTD_H=1
-DHAVE_STRUCT_STAT_ST_BLOCKS=1 -DHAVE_ST_BLOCKS=1 -DTIME_WITH_SYS_TIME=1
-DHAVE_LIBM=1 -DHAVE_PNG_H=1 -DHAVE_LIBPNG_PNG_H=1 -DHAVE_LIBX11=1
-DHAVE_LIBXEXT=1 -DHAVE_LIBXT=1 -DHAVE_MKSTEMP=1 -DHAVE_UNISTD_H=1 -DHAVE_FORK=1
-DHAVE_VFORK=1 -DHAVE_WORKING_VFORK=1 -DHAVE_WORKING_FORK=1 -DHAVE_STDLIB_H=1
-DHAVE_MALLOC=1 -DRETSIGTYPE=void -DLSTAT_FOLLOWS_SLASHED_SYMLINK=1
-DHAVE_VPRINTF=1 -DHAVE_BZERO=1 -DHAVE_DUP2=1 -DHAVE_FLOOR=1
-DHAVE_GETTIMEOFDAY=1 -DHAVE_MEMCHR=1 -DHAVE_MEMMOVE=1 -DHAVE_MEMSET=1
-DHAVE_MKDIR=1 -DHAVE_MKFIFO=1 -DHAVE_MODF=1 -DHAVE_POW=1 -DHAVE_PUTENV=1
-DHAVE_RINT=1 -DHAVE_SETENV=1 -DHAVE_SQRT=1 -DHAVE_STRCHR=1 -DHAVE_STRERROR=1
-DHAVE_STRRCHR=1 -DHAVE_STRSPN=1 -DHAVE_STRSTR=1 -I./obj -I./src -o
./obj/gxicolor.o -c ./src/gxicolor.c
./src/gxicolor.c: In function <CORRUPTION>
./src/gxicolor.c:143: warning: <CORRUPTION>
./src/gxicolor.c:120: warning: <CORRUPTION>
./src/gxicolor.c:120: warning: <CORRUPTION>
./obj/echogs -e .dev -w- -l-obj ./obj/colimlib ./obj/gxicolor.o
./obj/echogs -e .dev -a- ./obj/colimlib -imageclass 4_color
i486-linux-gnu-gcc -DHAVE_MKSTEMP -Wall -g -O2 -I/usr/include/glib-2.0
-I/usr/lib/glib-2.0/include -Wall -Wstrict-prototypes -Wmissing-declarations
-Wmissing-prototypes -Wcast-qual -Wwrite-strings -fno-builtin -fno-common
-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\"
-DPACKAGE_STRING=\"\" -DPACKAGE_BUGRE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VE_STRERROR=1
-DHAVE_STRRCHR=1 -DHAVE_STRSPN=1 -DHAVE_STRSTR=1 -I./src -I./obj -I./obj
-I./src -o ./obj/zcolor1.o -c ./src/zcolor1.c

I have replaced the erroneous characters with <CORRUPTION> above. Running the
same command from the shell in a more controlled manner shows the following:

ian@chinook:~/things/Ubuntu/gs-esp-7.07.1$ i486-linux-gnu-gcc -DHAVE_MKSTEMP
-Wall -g -O2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -Wall
-Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wcast-qual
-Wwrite-strings -fno-builtin -fno-common -DPACKAGE_NAME=\"\"
-DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\"
-DPACKAGE_BUGREPORT=\"\" -DHAVE_DIRENT_H=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1
-DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1
-DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1
-DHAVE_ERRNO_H=1 -DHAVE_FCNTL_H=1 -DHAVE_LIMITS_H=1 -DHAVE_MALLOC_H=1
-DHAVE_MEMORY_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_STRINGS_H=1
-DHAVE_SYS_IOCTL_H=1 -DHAVE_SYS_PARAM_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYSLOG_H=1
-DHAVE_UNISTD_H=1 -DHAVE_STRUCT_STAT_ST_BLOCKS=1 -DHAVE_ST_BLOCKS=1
-DTIME_WITH_SYS_TIME=1 -DHAVE_LIBM=1 -DHAVE_PNG_H=1 -DHAVE_LIBPNG_PNG_H=1
-DHAVE_LIBX11=1 -DHAVE_LIBXEXT=1 -DHAVE_LIBXT=1 -DHAVE_MKSTEMP=1
-DHAVE_UNISTD_H=1 -DHAVE_FORK=1 -DHAVE_VFORK=1 -DHAVE_WORKING_VFORK=1
-DHAVE_WORKING_FORK=1 -DHAVE_STDLIB_H=1 -DHAVE_MALLOC=1 -DRETSIGTYPE=void
-DLSTAT_FOLLOWS_SLASHED_SYMLINK=1 -DHAVE_VPRINTF=1 -DHAVE_BZERO=1 -DHAVE_DUP2=1
-DHAVE_FLOOR=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_MEMCHR=1 -DHAVE_MEMMOVE=1
-DHAVE_MEMSET=1 -DHAVE_MKDIR=1 -DHAVE_MKFIFO=1 -DHAVE_MODF=1 -DHAVE_POW=1
-DHAVE_PUTENV=1 -DHAVE_RINT=1 -DHAVE_SETENV=1 -DHAVE_SQRT=1 -DHAVE_STRCHR=1
-DHAVE_STRERROR=1 -DHAVE_STRRCHR=1 -DHAVE_STRSPN=1 -DHAVE_STRSTR=1 -I./obj
-I./src -o ./obj/gxicolor.o -c ./src/gxicolor.c 2>&1 | cat -vet
./src/gxicolor.c: In function M-bM-^@M-^Ximage_render_colorM-bM-^@M-^Y:$
./src/gxicolor.c:143: warning: M-bM-^@M-^XirunM-bM-^@M-^Y may be used
uninitialized in this function$
./src/gxicolor.c:120: warning: M-bM-^@M-^XvdiM-bM-^@M-^Y may be used
uninitialized in this function$
./src/gxicolor.c:120: warning: M-bM-^@M-^XvciM-bM-^@M-^Y may be used
uninitialized in this function$
ian@chinook:~/things/Ubuntu/gs-esp-7.07.1$

Revision history for this message
Matthias Klose (doko) wrote :

please attach the (compressed) preprocessed source to the report, and reassign
it back.

Revision history for this message
Matthias Klose (doko) wrote :

no warnings shown with current gs-esp version. Ian, should the report stay open?

Revision history for this message
Matthias Klose (doko) wrote :

current compilations don't show the warning

Changed in gcc-4.0:
assignee: ijackson → doko
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.