https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80753
Bug ID: 80753 Summary: __has_include and __has_include_next taints subsequent I/O errors Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: preprocessor Assignee: unassigned at gcc dot gnu.org Reporter: p...@gcc-bugzilla.mail.kapsi.fi Target Milestone: --- Created attachment 41356 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41356&action=edit __has_include testcase on a non-existent file Hi. It seems that whenever __has_include or __has_include_next is used, if the header file is non-existent (i.e. reading it would cause an I/O error) any subsequent #include on the same file will not fail, but error messages are silently tainted and preprocessing continues as if nothing happened. I tried pretty much every release since GCC 4.9 (up until the latest trunk), and they all behave the same. I couldn't find any information suggesting that this behaviour is to be expected and at least Clang (3.9) does not share this behaviour. $ cat has-include.c has-include-next.c #if __has_include(<nonesuch>) # error ".." #endif #include <nonesuch> #if __has_include_next(<nonesuch_next>) # error ".." #endif #include <nonesuch_next> $ gcc -E has-include.c has-include-next.c && echo ok # 1 "has-include.c" # 1 "<built-in>" # 1 "<command-line>" # 1 "has-include.c" # 1 "has-include-next.c" # 1 "<built-in>" # 1 "<command-line>" # 1 "has-include-next.c" ok