Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#74429 - [gcc] 11.2.0-4 compiling std::map with default flags and bits/stdc++.h header cause compiler error.

Attached to Project: Arch Linux
Opened by Hikari (Hikari) - Sunday, 10 April 2022, 03:50 GMT
Last edited by freswa (frederik) - Monday, 11 April 2022, 09:45 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To freswa (frederik)
Architecture x86_64
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
As stated above, using gcc version 11.2.0-4 to compile instance of std::map with no flag specified and header bits/stdc++.h included at the front will cause an `internal compiler error` and compilation fails. However, it's observed that compiling with optimization (flag `-O2`) or sanitizers (flag `-fsanitize=undefined`) is fine, compiling with only c++ header `map` included or `map` included before `bits/stdc++.h` will not cause any error either.

Way to Reproduce:
1. write a minimal c++ source file with only `bits/stdc++.h` included and a instance of std::map
```
$ cat main.cpp
#include <bits/stdc++.h>
std::map<int, int> s;

int main() { return 0; }
```
2. compile with command `g++ main.cpp`
```
$ g++ main.cpp
during RTL pass: expand
In file included from /usr/include/c++/11.2.0/map:60,
from /usr/include/c++/11.2.0/x86_64-pc-linux-gnu/bits/stdc++.h:81:
/usr/include/c++/11.2.0/bits/stl_tree.h: In constructor ‘std::_Rb_tree_header::_Rb_tree_header()’:
/usr/include/c++/11.2.0/bits/stl_tree.h:176:15: internal compiler error: in expand_UBSAN_NULL, at internal-fn.c:444
176 | _M_reset();
| ~~~~~~~~^~
0xe4c988 internal_error(char const*, ...)
???:0
0xe42d02 fancy_abort(char const*, int, char const*)
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://bugs.archlinux.org/> for instructions.
```

output of `gcc -v main.cpp` is attached as verbose_output_gcc.txt.

The error will trigger as long as `bits/stdc++.h` is included first.
```
#include <bits/stdc++.h>
#include <map>
std::map<int, int> s;

int main() { return 0; }
```
code above will trigger the error, but source codes below will all compile just file.
```
#include <map>
#include <bits/stdc++.h>
std::map<int, int> s;

int main() { return 0; }
```
```
#include <map>
std::map<int, int> s;

int main() { return 0; }
```
This task depends upon

Closed by  freswa (frederik)
Monday, 11 April 2022, 09:45 GMT
Reason for closing:  Not a bug
Comment by Hikari (Hikari) - Monday, 11 April 2022, 01:10 GMT
Sorry for disturbing, but I think the issue is caused by a pre-compiled header that was created before I updated gcc which I completely forgot of.
With the .gch file removed the issue is solved.
Apologize for any confusion caused by the false claim.

Loading...