Bug 42921 - No error with missing header and -MM
Summary: No error with missing header and -MM
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-01 03:50 UTC by Richard Hansen
Modified: 2018-08-31 16:19 UTC (History)
8 users (show)

See Also:
Host: x86_64-linux-gnu
Target: x86_64-linux-gnu
Build: x86_64-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2018-08-31 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Hansen 2010-02-01 03:50:11 UTC
The -MM option does not raise an error if the source includes a non-existent header using angle brackets:

$ echo "#include <does_not_exist.h>" > foo.c
$ gcc -MM -MF foo.d foo.c && echo succeeded || echo failed
succeeded
$ cat foo.d
foo.o: foo.c

Including a file using double quotes does produce an error as expected:

$ echo '#include "does_not_exist.h"' > foo.c
$ gcc -MM -MF foo.d foo.c && echo succeeded || echo failed
foo.c:1:28: fatal error: does_not_exist.h: No such file or directory
compilation terminated.
failed

Seen in current trunk:
$ gcc -v
Using built-in specs.
COLLECT_GCC=./install/bin/gcc
COLLECT_LTO_WRAPPER=/home/rhansen/gcc_build/install/libexec/gcc/x86_64-unknown-linux-gnu/4.5.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --prefix=/home/rhansen/gcc_build/install --with-local-prefix=/home/rhansen/gcc_build/install --enable-languages=c
Thread model: posix
gcc version 4.5.0 20100131 (experimental) [trunk revision 156418] (GCC)

And in 4.4.1 from Ubuntu Karmic:
$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.1-4ubuntu9' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9)
Comment 1 Andrew Pinski 2010-02-07 20:33:16 UTC

*** This bug has been marked as a duplicate of 28435 ***
Comment 2 Richard Hansen 2010-02-08 05:33:05 UTC
Reopening; this is a different issue than bug 28435.

Chris Demetriou in bug 28435, comment 16 says:
> FWIW, I actually think that's a different issue (though certainly related).
>
> this bug was all about -MD and -MMD -- and what happens when an object file 
> needs to be output, but cannot be because of a missing include.
>
> AFAICT, that bug is all about, what should the handling of -MM be vs. 
> missing system headers.
>
> That having been said, I will note that with:
> gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
>
> you get the results:
>
> [cgd@laptop tmp]$ echo "#include <does_not_exist.h>" > foo.c
> [cgd@laptop tmp]$ gcc -MM -MF foo.d foo.c && echo succeeded || echo failed
> foo.c:1:28: does_not_exist.h: No such file or directory
> failed
> [cgd@laptop tmp]$ echo '#include "does_not_exist.h"' > foo.c
> [cgd@laptop tmp]$ gcc -MM -MF foo.d foo.c && echo succeeded || echo failed
> foo.c:1:28: does_not_exist.h: No such file or directory
> failed
>
> So this certainly used to behave as the submitter of 42921 expected at 
> *some* point.
>
> As of 4.2.2 (the next version I have handy after 3.4.4) the first case 
> reported "succeeded" (and the second failed).
>
> --cgd
Comment 3 Shakthi Kannan 2013-05-08 05:30:25 UTC
Confirmed.

$ ./install/bin/gcc -MM -MF foo.d foo.c && echo succeeded || echo failed 
succeeded

$ ./install/bin/gcc -v
Using built-in specs.
COLLECT_GCC=./install/bin/gcc
COLLECT_LTO_WRAPPER=/home/mbuf/testing/gcc/42921/install/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --prefix=/home/mbuf/testing/gcc/42921/install
Thread model: posix
gcc version 4.9.0 20130507 (experimental) (GCC)