[Bug c++/104403] [12 Regression] ICE while optimizing lambda that returns address of a static variable hidden in a switch

2022-02-05 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104403

Jakub Jelinek  changed:

   What|Removed |Added

   Last reconfirmed||2022-02-05
   Target Milestone|--- |12.0
   Priority|P3  |P1
 Status|UNCONFIRMED |NEW
 CC||jakub at gcc dot gnu.org
Summary|ICE while optimizing lambda |[12 Regression] ICE while
   |that returns address of a   |optimizing lambda that
   |static variable hidden in a |returns address of a static
   |switch  |variable hidden in a switch
 Ever confirmed|0   |1

--- Comment #1 from Jakub Jelinek  ---
Started with r12-4206-g8892d532d66910e518bc135a851a104322385ca2

[Bug c++/104403] [12 Regression] ICE while optimizing lambda that returns address of a static variable hidden in a switch

2022-02-07 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104403

Jakub Jelinek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek  ---
Created attachment 52363
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52363&action=edit
gcc12-pr104403.patch

Untested fix.

[Bug c++/104403] [12 Regression] ICE while optimizing lambda that returns address of a static variable hidden in a switch

2022-02-08 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104403

--- Comment #3 from CVS Commits  ---
The master branch has been updated by Jakub Jelinek :

https://gcc.gnu.org/g:1755141a9ea0dddabb52776cddc4c9325eed27c6

commit r12-7112-g1755141a9ea0dddabb52776cddc4c9325eed27c6
Author: Jakub Jelinek 
Date:   Tue Feb 8 20:15:42 2022 +0100

c++: Remove superflous assert [PR104403]

I've added the assert because start_decl diagnoses such vars for C++20 and
earlier:
  if (current_function_decl && VAR_P (decl)
  && DECL_DECLARED_CONSTEXPR_P (current_function_decl)
  && cxx_dialect < cxx23)
but as can be seen, we cam trigger the assert in older standards e.g.
during
non-manifestly constant evaluation.  Rather than refining the assert that
DECL_EXPRs for such vars don't appear for C++20 and older if they are
inside
of functions declared constexpr this patch just removes the assert, the
code rejects encountering those vars in constant expressions anyway.

2022-02-08  Jakub Jelinek  

PR c++/104403
* constexpr.cc (cxx_eval_constant_expression): Don't assert
DECL_EXPRs
of TREE_STATIC vars may only appear in -std=c++23.

* g++.dg/cpp0x/lambda/lambda-104403.C: New test.

[Bug c++/104403] [12 Regression] ICE while optimizing lambda that returns address of a static variable hidden in a switch

2022-02-08 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104403

Jakub Jelinek  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #4 from Jakub Jelinek  ---
Fixed.