https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91380
Bug ID: 91380
Summary: Requesting a better diagnostic for dumb include
mistake
Product: gcc
Version: 9.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: barry.revzin at gmail dot com
Target Milestone: ---
We just had an example in our codebase which did the moral equivalent of:
#include "<vector>"
gcc's diagnostic for this is:
<source>:1:10: fatal error: <vector>: No such file or directory
1 | #include "<vector>"
| ^~~~~~~~~~
It's very subtle to notice that we accidentally used both ""s and <>s (indeed
we spent a significant amount of time trying to figure out why the file
couldn't be found despite definitely being there... the real example used a
non-system header).
clang's diagnostic for this is:
<source>:1:10: error: '<vector>' file not found, did you mean 'vector'?
#include "<vector>"
^~~~~~~~~~
"vector"
It's not based on knowing what vector is, it gives equivalently good
diagnostics based on actually search include paths. e.g. if I put a foo.h in
include/ and run clang++ -c foo.cxx -Iinclude where I'm trying to #include
"<foo.h>" I get:
foo.cxx:1:10: error: '<foo.h>' file not found, did you mean 'foo.h'?
#include "<foo.h>"
^~~~~~~~~
"foo.h"
This is super low priority, but I figure somebody else may have run into this
problem in the past and also spent a while ripping their hair out as to why
some file couldn't be found, so I thought I'd at least get it on your radar.
Thank you.