public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114488] New: internal compiler error: unexpected expression static_cast ...
@ 2024-03-26 17:04 ing.russomauro at gmail dot com
  2024-03-26 17:21 ` [Bug c++/114488] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: ing.russomauro at gmail dot com @ 2024-03-26 17:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114488

            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 <memory>

int main(){
    const auto b = std::make_shared<int>(1);

    [b](const auto& v) {
        const auto u = static_cast<short>(b ? 1 : 3);
    }(2);
}

/* END CODE */

The compiler message reads:

internal compiler error: unexpected expression 'static_cast<short int>((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=c++14" or "-std=gnu++14" or "-std=c++17" or "-std=gnu++17" or
"-std=c++2a" or "-std=gnu++2a" (it seems C++14 is the default; nonetheless,
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 kind 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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-03-26 21:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-26 17:04 [Bug c++/114488] New: internal compiler error: unexpected expression static_cast ing.russomauro at gmail dot com
2024-03-26 17:21 ` [Bug c++/114488] " pinskia at gcc dot gnu.org
2024-03-26 17:25 ` ing.russomauro at gmail dot com
2024-03-26 17:30 ` redi at gcc dot gnu.org
2024-03-26 20:58 ` redi at gcc dot gnu.org
2024-03-26 21:40 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).