Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

__STDC_IEC_559__ depends on #include <stdio.h>: confused #51500

Open Quuxplusone opened 2 years ago

Quuxplusone commented 2 years ago
Bugzilla Link PR52533
Status NEW
Importance P normal
Reported by Pavel Morozkin (pavel.morozkin@gmail.com)
Reported on 2021-11-17 04:19:48 -0800
Last modified on 2021-11-18 02:26:34 -0800
Version trunk
Hardware PC Linux
CC blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk, xtkoba@gmail.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Note: this may not be a bug. However, it is expected that __STDC_IEC_559__ does
not depend on any #include and stays constant during the translation.

This code:
#include FNAME
#if __STDC_IEC_559__ == 1
#pragma message "__STDC_IEC_559__ is 1"
#else
#pragma message "__STDC_IEC_559__ is not 1"
#endif

compiled with:
$ clang t0.c -std=c11 -pedantic -Wall -Wextra -DFNAME="<stdio.h>"

leads to:
t0.c:3:9: warning: __STDC_IEC_559__ is 1 [-W#pragma-messages]

while compiled with:
$ clang t0.c -std=c11 -pedantic -Wall -Wextra -DFNAME="<float.h>"

leads to:
t0.c:3:9: warning: __STDC_IEC_559__ is not 1 [-W#pragma-messages]

Here we see that the value of __STDC_IEC_559__ depends on #include. Which is
confusing. Please explain / investigate.

Version: clang 13.0.0 on Linux on x86_64
Quuxplusone commented 2 years ago

Probably related to https://bugs.llvm.org/show_bug.cgi?id=32377.

If were pre-included for GNU/Linux, STDC_IEC_559 would be set to 1 regardless of further #includes of system headers.

I wonder if https://reviews.llvm.org/rG5c086c7626fab2617c0178a3951378bcbce2271c is not effective any more, which should have fixed this issue.

Quuxplusone commented 2 years ago

Ah, the commit seems to have been reverted for some reason.

Differential Revision: https://reviews.llvm.org/D34158