From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0AF843858C60; Tue, 26 Mar 2024 17:04:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0AF843858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711472656; bh=b3tZAqGOtDmkquaG0pa9/Wx9rC0UZb7lfWxw+0NpvHU=; h=From:To:Subject:Date:From; b=gKuL5cA90WPHsl0xcKTrV21TudDXm+Ul81MGJfCf/zueLFENiLGhek1A+Ajz9JU3q DIMWCkOqMiEz9G9mBqxQn1OipAv0Z+7dG2rxMuV0cMP1YIBjU9/AOqeNT3dk/WCIoL 8IbX12wfLnS+L0Vyqu5Kd9ve6yYOZ6bEgkubOB8g= From: "ing.russomauro at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114488] New: internal compiler error: unexpected expression static_cast ... Date: Tue, 26 Mar 2024 17:04:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 9.5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ing.russomauro at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114488 Bug ID: 114488 Summary: internal compiler error: unexpected expression static_cast ... Product: gcc Version: 9.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ing.russomauro at gmail dot com Target Milestone: --- The error is reproduced on godbolt online compiler with gcc 9.5. It was initially experienced on a local machine. /* BEGIN CODE */ #include int main(){ const auto b =3D std::make_shared(1); [b](const auto& v) { const auto u =3D static_cast(b ? 1 : 3); }(2); } /* END CODE */ The compiler message reads: internal compiler error: unexpected expression 'static_cast((b ?= 1 : 3))' of kind static_cast_expr Note that the same happens with the gcc versions 9.4 and 10.2, whereas 9.3, 10.1, 10.3, and 13.2 do not present the error (not applicable to version 9.2 for unsupported features). Not checked on intermediate versions between 10.3 and 13.2. The error arises even adding options to the compiler on godbolt, as "-std=3Dc++14" or "-std=3Dgnu++14" or "-std=3Dc++17" or "-std=3Dgnu++17" or "-std=3Dc++2a" or "-std=3Dgnu++2a" (it seems C++14 is the default; nonethel= ess, does not affect the resulting internal error). The error is confirmed even with options either "-Wall -Wextra" or "-fno-strict-aliasing -fwrapv". Among the possible duplicates, 63415 has the most similar title but the kin= d of source code appears different, I cannot guess whether the root cause was overlapped or not, taking also into account that 63415 is for version 4.9.1= and above I mentioned that version 9.2 is not capable to compile my posted code= for missing features.=