Re: -std=c90 -pedantic-errors and <stdint.h>

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx> - 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)



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux