This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c/4967: GCC should warn about obvious violations of restrict
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- To: Andreas Jaeger <aj at suse dot de>
- Cc: <gcc-gnats at gcc dot gnu dot org>, <ma at suse dot de>, <gcc-bugs at gcc dot gnu dot org>
- Date: Thu, 29 Nov 2001 12:40:56 +0000 (GMT)
- Subject: Re: c/4967: GCC should warn about obvious violations of restrict
[Get raw message]
On Thu, 29 Nov 2001, Andreas Jaeger wrote:
> The compiler should use the restrict keyword of ISO C99 when invoking
> functions and check that the aliasing rules are not violated on the
> call side.
Why? The keyword provides no information whatsoever to the call side,
since the function needn't access the objects pointed to by its arguments
at all.
> Compile this program - it should give a warning:
> int
> sprintf_restrict (char *restrict s, const char *restrict t)
> {
> return *s!=*t;
> }
>
>
>
> int main (void)
> {
> char buf[64];
>
> sprintf_restrict (buf, buf);
>
> return 0;
> }
The program is perfectly valid; while sprintf_restrict could have a const
on the target type of its first parameter, there's no need for it to have
one.
--
Joseph S. Myers
jsm28@cam.ac.uk