Why removing line information from a preprocessed C++ source code makes it fail to compiler?

Viewed 61

Example

clang++-8 -std=c++11 somefile.cpp -E > q.e
clang++-8 -std=c++11 -x c++ q.e -c -o q.o

Works as expected.

Let's remove line information, like this:

# 1 "somefile.cpp"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 380 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "somefile.cpp" 2
# 1 "../someheader.h" 1
# 1 "/usr/include/clang/8.0.1/include/stdint.h" 1 3
# 61 "/usr/include/clang/8.0.1/include/stdint.h" 3
# 1 "/usr/include/stdint.h" 1 3 4

cat q.e | grep -v  '^# ' > qq.e

clang++-8 -std=c++11 -x c++ qq.e -c -o q.o

qq.e:238:20: warning: '__format__' attribute argument not supported: gnu_printf [-Wignored-attributes]
    __attribute__((__format__(__gnu_printf__, 1, 2)));
                   ^
qq.e:311:12: warning: keyword '__is_void' will be made available as an identifier for the remainder of the translation unit [-Wkeyword-compat]
    struct __is_void

(many more warnings)

qq.e:36194:3: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
  acos(float __x)

...

fatal error: too many errors emitted, stopping now [-ferror-limit=]

Question

Why removing information that is supposedly should only affect messages from compiler actually affects compilation outcome?

0 Answers
Related