[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: small header change to correct an unnecessary compiler warning
From: |
Andreas Jaeger |
Subject: |
Re: small header change to correct an unnecessary compiler warning |
Date: |
Thu, 12 Jul 2001 07:07:18 +0200 |
User-agent: |
Gnus/5.090004 (Oort Gnus v0.04) XEmacs/21.4 (Academic Rigor) |
Agthorr <address@hidden> writes:
> I'm running GNU libc version 2.2.3.
>
> I recently noticed that the function strtol() is declared as follows:
>
> extern long int strtol (__const char *__restrict __nptr,
> char **__restrict __endptr, int __base) __THROW;
>
> This causes a warning to be generated unnecessarily for the following
> perfectly legimate code:
>
> ------------------------------------------------------------------------
> #include <stdlib.h>
>
> int main(void) {
> char bloop[] = "123";
> const char *foo = bloop;
>
> strtol (foo, &foo, 0);
>
> return 0;
>}
> ------------------------------------------------------------------------
It's not legal code - strtol assigns a value to foo afterwards and
with the restrict you explicitly say that those two do not alias each
other.
Your changes are therefore wrong - and we can't change it since
standards (ISO C99) mandate the prototype exactly as we have it.
Andreas
--
Andreas Jaeger
SuSE Labs address@hidden
private address@hidden
http://www.suse.de/~aj