Bad gcc -O optimization cause core dump. What to do?

Max Laier max at love2party.net
Tue Mar 13 12:33:14 UTC 2007


On Tuesday 13 March 2007 13:11, Andrey Chernov wrote:
> Copy the segment below to the file a.c
> ---------------------- cut me here ---------------------
> #include <stdio.h>
>
> main() {
> printf("%s\n", NULL);
> }
> ---------------------- cut me here ---------------------
> Compile first as
> cc a.c
> ./a.out
> got
> (null)
> Then compile as
> cc -O a.c
> ./a.out
> got core dump.
...
> It calls "puts(NULL)" with core dump.
> It means "printf("%s\n", NULL)" is overoptimized.
> BTW, things like "printf("1%s\n", NULL)" are not overoptimized.
> Any ideas? Is it right or needs to be fixed?

See: http://www.ciselant.de/projects/gcc_printf/gcc_printf.html 3.1

-- 
/"\  Best regards,                      | mlaier at freebsd.org
\ /  Max Laier                          | ICQ #67774661
 X   http://pf4freebsd.love2party.net/  | mlaier at EFnet
/ \  ASCII Ribbon Campaign              | Against HTML Mail and News
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20070313/67f06a09/attachment.pgp


More information about the freebsd-current mailing list