-std=c90 -pedantic-errors and <stdint.h>
Vincent Lefevre
vincent+gcc@vinc17.org
Tue May 30 23:23:00 GMT 2017
On 2017-05-30 23:04:02 +0200, Florian Weimer wrote:
> * Vincent Lefevre:
>
> > Is it normal that -std=c90 -pedantic-errors allows to use
> >
> > #include <stdint.h>
> >
> > ?
>
> Yes. It's difficult where to draw the line. <inttypes.h> was
> apparently available with some C90 compilers, so it would make sense
> to allow it in C90 mode. But this means that it wouldn't be
> completely out of line to accept <stdint.h>, too.
Now, what actually mattered in my case was the use of (u)intmax_t.
For instance, consider the following program:
#include <stdio.h>
#include <stdint.h>
#include <limits.h>
int main (void)
{
uintmax_t i = -1;
printf ("%d\n", i > ULONG_MAX);
return 0;
}
In C90, "long" is the largest type, so that one should always expect
the output 0. But:
cventin:~> gcc -std=c90 -pedantic-errors -o tst tst.c -m32
cventin:~> ./tst
1
under GNU/Linux.
IMHO, at least some features of <stdint.h> should yield a warning
with -pedantic (an error with -pedantic-errors).
--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
More information about the Gcc-help
mailing list