Bug#299188: gcc: -ffreestanding and builtins don't work as expected
On Sat, Mar 12, 2005 at 04:48:46PM +0100, Thiemo Seufer wrote:
> Adrian Bunk wrote:
> [snip]
> > #define sprintf __builtin_sprintf
> >
> > int main()
> > {
> > char str[] = "abc";
> > char buf[10];
> >
> > sprintf(buf,"%s",str);
> >
> > return 0;
> > }
> [snip]
> > call strcpy
> [snip]
> > As far as I understand the documentation, the call to strcpy
> > shouldn't be emitted since this function is not required in a
> > freestanding environment.
> >
> > gcc-3.3 and gcc-4.0 behave similar.
> >
> > I'm not sure whether this is expected, but if it is, the documentation
> > should be updated.
>
> You explicitly requested the __builtin_sprintf implementation, which is
> allowed to decay to strcpy, and overrode the -ffreestanding in this
> case. AFAICS the documentation is correct (but not that explicit for
> that cornercase).
The documentation I quoted in my bug report says, that __builtin was a
way to re-enable a builtin in a freestanding environment.
My point is simply, that I'm surprised that this may cause a call to a
different function.
> Thiemo
cu
Adrian
--
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed
Reply to: