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

* [Bug c++/114488] internal compiler error: unexpected expression static_cast ...
  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 ` pinskia at gcc dot gnu.org
  2024-03-26 17:25 ` ing.russomauro at gmail dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-26 17:21 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=97975
           Keywords|                            |ice-on-valid-code
         Resolution|---                         |FIXED

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So this was fully fixed for GCC 10.3.0 and GCC 11+. See PR 97975 .

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

* [Bug c++/114488] internal compiler error: unexpected expression static_cast ...
  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
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ing.russomauro at gmail dot com @ 2024-03-26 17:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from mauro russo <ing.russomauro at gmail dot com> ---
If something is removed from sample code (e.g., b made bool instead of a
shared_ptr, or some const is removed), the problem disappears.

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

* [Bug c++/114488] internal compiler error: unexpected expression static_cast ...
  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
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2024-03-26 17:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
An ICE seems to have started on trunk with r11-122 and been fixed by r11-557

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

* [Bug c++/114488] internal compiler error: unexpected expression static_cast ...
  2024-03-26 17:04 [Bug c++/114488] New: internal compiler error: unexpected expression static_cast ing.russomauro at gmail dot com
                   ` (2 preceding siblings ...)
  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
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2024-03-26 20:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
On the gcc-9 branch the first bad commit is r9-8623-g0296697cf9893d

commit 0296697cf9893dc9509cdcd8e3fd4ba9fe422527
Author: Jason Merrill
Date:   Mon May 25 18:38:09 2020 -0400

    c++: constexpr and lambda capture [PR90212]

    This is the same issue as PR86429, just in potential_constant_expression_1
    rather than cxx_eval_constant_expression.  As in that case, when we're
    trying to evaluate a constant expression within a lambda, we don't have a
    constant closure object to refer to, but we can try to refer directly to
the
    captured variable.

            PR c++/90212
            * constexpr.c (potential_constant_expression_1): In a lambda
            function, consider a captured variable directly.

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

* [Bug c++/114488] internal compiler error: unexpected expression static_cast ...
  2024-03-26 17:04 [Bug c++/114488] New: internal compiler error: unexpected expression static_cast ing.russomauro at gmail dot com
                   ` (3 preceding siblings ...)
  2024-03-26 20:58 ` redi at gcc dot gnu.org
@ 2024-03-26 21:40 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2024-03-26 21:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #4)
> On the gcc-9 branch the first bad commit is r9-8623-g0296697cf9893d

Which was the backport of r11-122.

And as expected, the ICE began on gcc-10 with the gcc-10 backport of r11-122,
which was r10-8183-gaa613a81831bdc

It was fixed for gcc-10 by r10-9207-gd0684e49ee8d85 which is the backport for
PR 97975, as Andrew said in comment 1.

^ 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).