Internal Compiler Error in cxx_eval_call_expression with C++20 Modules and constexpr Expansion and inputs may not also have inputs

Bug #2052797 reported by Eduardo Dantas
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc-12 (Ubuntu)
New
Undecided
Unassigned

Bug Description

I encountered an internal compiler error (ICE) while building a C++ project using C++20 modules. The error occurs during the compilation of a constructor that involves `constexpr` expansion of `std::__cxx11::basic_string<char>`. The issue seems related to the handling of `constexpr` expressions and module imports.

Environment:
- Compiler: GCC 12 (also with GCC 13)
- OS: Ubuntu 22.04 (WSL), also with normal Ubuntu
- Build System: CMake with Ninja generator

Error Message:
[ 29%] Building CXX object src/CMakeFiles/canary_lib.dir/Unity/unity_21_cxx.cxx.o
In module imported at /home/ubuntu/canary/src/lua/lua_definitions.hpp:12:1,
...
included from /home/ubuntu/canary/src/server/signals.cpp:12,
from /home/ubuntu/canary/build/src/CMakeFiles/canary_lib.dir/Unity/unity_21_cxx.cxx:4:
game_movement: note: unable to represent further imported source locations
...
/home/ubuntu/canary/src/creatures/interactions/chat.hpp:85:51: internal compiler error: in cxx_eval_call_expression, at cp/constexpr.cc:2836
85 | ChatChannel(channelId, channelName) { }
| ^
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See file:///usr/share/doc/gcc-12/README.Bugs for instructions.

Steps to Reproduce:
1. Compile the project using GCC 12 with C++20 modules enabled.
2. Observe the internal compiler error during the `constexpr` expansion in the constructor.

Expected Behavior:
The compiler should handle `constexpr` expansions without crashing, especially in the context of C++20 modules.

Actual Behavior:
The compiler crashes with an internal compiler error, indicating a potential issue in `cxx_eval_call_expression` related to `constexpr` expansion and module handling.

Additional Context:
- The error seems to be triggered by a specific interaction between C++20 modules and `constexpr` expansions.
- I have attempted to isolate the problem to a minimal example but found that it specifically occurs in the context of our project's structure and module imports.

Please let me know if additional information or a minimal reproducible example is needed to investigate this issue further. Thank you for your assistance in addressing this compiler bug.

The project I'm testing is this: https://github.com/opentibiabr/canary/pull/2189

The steps to the error:
Generate a cache: cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=/home/ubuntu/vcpkg/scripts/buildsystems/vcpkg.cmake
Compile: cmake --build build

I encountered another issue as well, related to inputs, which occurs when I compile using cmakepresets. If I compile without it, I encounter the constexpr issue mentioned earlier. The other error I'm referring to is as follows:
[1/44] Building CXX object src/CMakeFiles/ModulesLib.dir/game/info/light_info.ixx.o
FAILED: src/CMakeFiles/ModulesLib.dir/game/info/light_info.ixx.o
/usr/bin/c++ -I/home/runner/work/canary/canary/build/vcpkg_installed/x64-linux/include/mysql -flto=auto -flto=auto -O3 -DNDEBUG -std=gnu++20 -flto=auto -fno-fat-lto-objects -fPIC -fmodules-ts -x c++ -Wno-deprecated-declarations -fopenmp -MD -MT src/CMakeFiles/ModulesLib.dir/game/info/light_info.ixx.o -MF src/CMakeFiles/ModulesLib.dir/game/info/light_info.ixx.o.d -o src/CMakeFiles/ModulesLib.dir/game/info/light_info.ixx.o -c /home/runner/work/canary/canary/src/game/info/light_info.ixx
inputs may not also have inputs[2/44] Building CXX object src/CMakeFiles/ModulesLib.dir/enums/enum_modules.ixx.o

The project I'm testing is this: https://github.com/opentibiabr/canary/pull/2189
GitHub Actions error: https://github.com/opentibiabr/canary/actions/runs/7839809013/job/21393442847?pr=2189

The steps to the error:
Generate a cache: cmake -DCMAKE_TOOLCHAIN_FILE=/home/ubuntu/vcpkg/scripts/buildsystems/vcpkg.cmake .. --preset Linux-release
Compile: cmake --build Linux-release

summary: Internal Compiler Error in cxx_eval_call_expression with C++20 Modules
- and constexpr Expansion
+ and constexpr Expansion and inputs may not also have inputs
description: updated
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.