http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60007
Bug ID: 60007 Summary: preprocessor aborts with internal error when redefining a flag set by -D option Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: preprocessor Assignee: unassigned at gcc dot gnu.org Reporter: lutzwei at gmx dot de Consider the following program stored in file "test.c" : ------------------------- #define ANY_FLAG int main() { int i=1;} ------------------------- If you issue the command cpp -DANY_FLAG test.c you get an internal compiler error abort as follows: ---------------------------------------------------------------------- # 1 "test.c" # 1 "<command-line>" # 1 "test.c" test.c:1:0: warning: "ANY_FLAG" redefined [enabled by default] #define ANY_FLAG ^ <command-line>:0:0: note: this is the location of the previous definition test.c:1:0: internal compiler error: Segmentation fault #define ANY_FLAG ^ 0x99c5bf crash_signal ../../gcc-4.9.0/gcc/toplev.c:337 0xf0d747 add_file_to_cache_tab ../../gcc-4.9.0/gcc/input.c:296 0xf0d747 lookup_or_add_file_to_cache_tab ../../gcc-4.9.0/gcc/input.c:330 0xf0d747 location_get_source_line(expanded_location, int*) ../../gcc-4.9.0/gcc/input.c:704 0xf0868b diagnostic_show_locus(diagnostic_context*, diagnostic_info const*) ../../gcc-4.9.0/gcc/diagnostic.c:304 0xf096cb diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*) ../../gcc-4.9.0/gcc/diagnostic.c:800 0x5cd9f4 c_cpp_error(cpp_reader*, int, int, unsigned int, unsigned int, char const*, __va_list_tag (*) [1]) ../../gcc-4.9.0/gcc/c-family/c-common.c:9639 0xf17ef6 cpp_error_with_line(cpp_reader*, int, unsigned int, unsigned int, char const*, ...) ../../gcc-4.9.0/libcpp/errors.c:163 0xf27f4f _cpp_create_definition ../../gcc-4.9.0/libcpp/macro.c:3124 0xf146f1 do_define ../../gcc-4.9.0/libcpp/directives.c:584 0xf15f27 _cpp_handle_directive ../../gcc-4.9.0/libcpp/directives.c:492 0xf22a2c _cpp_lex_token ../../gcc-4.9.0/libcpp/lex.c:2067 0xf2761f cpp_get_token_1 ../../gcc-4.9.0/libcpp/macro.c:2362 0x5e995f scan_translation_unit ../../gcc-4.9.0/gcc/c-family/c-ppoutput.c:176 0x5e995f preprocess_file(cpp_reader*) ../../gcc-4.9.0/gcc/c-family/c-ppoutput.c:101 0x5e8378 c_common_init() ../../gcc-4.9.0/gcc/c-family/c-opts.c:1040 0x57aacd c_objc_common_init() ../../gcc-4.9.0/gcc/c/c-objc-common.c:65 0x99e616 lang_dependent_init ../../gcc-4.9.0/gcc/toplev.c:1712 0x99e616 do_compile ../../gcc-4.9.0/gcc/toplev.c:1900 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. ---------------------------------------------------------------------- The preprocessor version is: -bash-4.1$ cpp -v ---------------------------------------------------------------------- Using built-in specs. COLLECT_GCC=cpp Target: x86_64-unknown-linux-gnu Configured with: ../gcc-4.9.0/configure LDFLAGS=-Wl,-rpath,/home/datanumerik/archiv/software/linux64/gcc-4.9.0/gcc/lib --prefix=/home/datanumerik/archiv/software/linux64/gcc-4.9.0/gcc --with-gmp=/home/datanumerik/archiv/software/linux64/gcc-4.9.0/gcc --with-mpfr=/home/datanumerik/archiv/software/linux64/gcc-4.9.0/gcc --with-mpc=/home/datanumerik/archiv/software/linux64/gcc-4.9.0/gcc --with-gcc-version-trigger=/work/weimann/installs/gcc-4.9.0/gcc/version.c --enable-languages=c,c++,f95 --disable-multilib Thread model: posix gcc version 4.9.0 20140124 (experimental) (GCC) COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=x86-64' /nfs/datanumerik/archiv/software/linux64/gcc-4.9.0/gcc/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/cc1 -E -quiet -v -iprefix /nfs/datanumerik/archiv/software/linux64/gcc-4.9.0/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/ - -mtune=generic -march=x86-64 ignoring nonexistent directory "/nfs/datanumerik/archiv/software/linux64/gcc-4.9.0/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../x86_64-unknown-linux-gnu/include" ignoring duplicate directory "/nfs/datanumerik/archiv/software/linux64/gcc-4.9.0/gcc/bin/../lib/gcc/../../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/include" ignoring duplicate directory "/nfs/datanumerik/archiv/software/linux64/gcc-4.9.0/gcc/bin/../lib/gcc/../../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/include-fixed" ignoring nonexistent directory "/nfs/datanumerik/archiv/software/linux64/gcc-4.9.0/gcc/bin/../lib/gcc/../../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../x86_64-unknown-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /nfs/datanumerik/archiv/software/linux64/gcc-4.9.0/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/include /nfs/datanumerik/archiv/software/linux64/gcc-4.9.0/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/include-fixed /usr/local/include /nfs/datanumerik/archiv/software/linux64/gcc-4.9.0/gcc/bin/../lib/gcc/../../include /usr/include End of search list. ---------------------------------------------------------------------- The platform: -bash-4.1$ uname -a ---------------------------------------------------------------------- Linux htc031.zib.de 3.8.13-16.2.1.el6uek.x86_64 #1 SMP Thu Nov 7 17:01:44 PST 2013 x86_64 x86_64 x86_64 GNU/Linux ---------------------------------------------------------------------- I also reproduced the same problem under WindowsPro8.1/CYGWIN-32bit.