This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Set behavior of sprintf-like functions with overlapping source and destination


On 27/12/18 12:26 AM, Paul Eggert wrote:
It may not be too hard for the compiler to see this undefined behaviour and warn about it either, at least in some trivial cases...

Yes, that'd be good.

Turns out the compiler does identify aliases in this case (although in a very generic way because of which the warning may not be super-clear to a lot of devs at first glance):

foo.c:9:11: warning: passing argument 1 to restrict-qualified parameter aliases with argument 3 [-Wrestrict]
   sprintf(buf, "%sCD", buf);
           ^~~          ~~~

So I suppose we have this part covered.

Siddhesh


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]