Closed
Description
Way to reproduce
Create 1.cpp
(CRLF line endings)
#include "1.h"
Create 1.h
(LF line endings, whitespace is important)
#if 1
static_assert(__LINE__ == 2, "");
#endif
Try to compile
$ clang++ -E -frewrite-includes 1.cpp | clang++ -c -x c++ -
In file included from 1.cpp:1:
./1.h:3:1: error: static assertion failed due to requirement '3 == 2':
static_assert(__LINE__ == 2, "");
^ ~~~~~~~~~~~~~
1 error generated.
Tested on
clang version 15.0.5
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/15/bin
Configuration file: /etc/clang/clang++.cfg
and
clang version 13.0.1
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: <redacted>
Additional info
Bug doesn't reproduce if -frewrite-includes
is omitted.
Bug doesn't reproduce if whitespace in front of #if 1
is removed.
Bug doesn't reproduce if both 1.h
and 1.cpp
have same line endings.
Bug reproduces if CRLF/LF is swapped - 1.cpp
has LF and 1.h
has CRLF.
Bug reproduces if whitespace in front of #if 1
is replaced with TAB.