https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116722
Bug ID: 116722 Summary: Internal Compiler Error: when creating a class with virtual inheritance, constexpr template constructor and call it with floating point Product: gcc Version: 14.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: invisparent at outlook dot com Target Milestone: --- This code: class base {}; class derived : virtual public base { public: template<typename Arg> constexpr derived(Arg) {} }; int main() { derived obj(1.); } will trigger an internal compiler error. I've tested on GCC13.2, 14.1 and 14.2(.0) with w64devkit on Windows and GCC13.2 on Ubuntu, with various flags(no flag, adjust optimization level, different C++ standard from 17 to 23, etc.) All of them report ICE. For example: (I'm using GCC14.2.0 on Windows, w64devkit 2.0.0) C:\Users\Invisparent\CLionProjects\Cpp23T1>gcc main.cpp main.cpp: In function 'int main()': main.cpp:12:19: internal compiler error: in fold_convert_loc, at fold-const.cc:2633 12 | derived obj(1.); | ^ Please submit a full bug report, with preprocessed source (by using -freport-bug). See <https://gcc.gnu.org/bugs/> for instructions. Finally, some interesting things: 1. if I do any of those changes below, GCC will not report an ICE: (1) line 2: delete "virtual". That means we no longer use virtual inheritance. (2) line 5: delete "constexpr" (3) for the constructor, make it no longer a template, only accept double (or some other floating points). 2. in main(), replace obj(1.) with: (1) obj(1): Okay(compile success, no ICE) (2) obj(static_cast<(any_floating_point_type)>(1)): ICE (3) obj(static_cast<(any_integer_type)>(1.)): Okay So I guess there's a problem when evaluating constexpr constructor, with virtual inheritance and floating point as parameters. PS. I've tried to debug this (and may fix it?) for two days but... That's harder than I've expected. So, what I can do is post this bug, and wait for some nice and clever volunteers to fix it. Thanks!