Re: optimizing out string functions when the string contains a NUL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ohav chochmah <philomath868@xxxxxxxxx> writes:

> #define HIDDEN "\0this string starts with a NUL"
> ...
> AFAICT, the puts and printf are both no-ops, as the C-string stops
> before it starts.  yet when doing 'gcc -S tst.c -O2 -march=native' or
> even 'gcc -S tst.c -O3 -march=native', GCC generates the following:
> ...
> in short, the printf was removed but not the puts.  which left me wondering why?

You are describing an optimization in which GCC looks in constant string
literals passed to puts and truncates them at \0.  Nobody has
implemented that optimization.  It sounds like it would affect very very
very few programs, so I'm not sure why anybody would bother to implement
it.  If anything I think it would be more useful to have a warning.  But
either way I don't think it's worth it.

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux