[Bug c++/126867] [16/17 regression] ICE after failed static_assert using __has_unique_object_representations in a concept since r16-5520

"cvs-commit at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126867

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-16 branch has been updated by Jakub Jelinek
<[email protected]>:

https://gcc.gnu.org/g:5e7fa6dbae546cdc07857be19cf3aa2375e9edad

commit r16-9552-g5e7fa6dbae546cdc07857be19cf3aa2375e9edad
Author: Jakub Jelinek <[email protected]>
Date:   Tue Aug 18 20:15:45 2026 +0200

    c++: Fix ICE during explanation of failed
__has_unique_object_representation [PR126867]

    The following testcase ICEs since r16-5520 added explain
    arguments to type_has_unique_obj_representations and
    record_has_unique_obj_representations.  Most of the location_t
    arguments in that change look correct, either DECL_SOURCE_LOCATION
    of some FIELD_DECL or in type_has_unique_obj_representations use
    loc, which is initialized to
      location_t loc = input_location;
      if (tree m = TYPE_MAIN_DECL (t))
        loc = DECL_SOURCE_LOCATION (m);
    But in record_has_unique_obj_representations we don't have
    a variable like that and t at that point is the RECORD_TYPE
    or UNION_TYPE, so using DECL_SOURCE_LOCATION on it will surely ICE
    in a checking compiler.
    location_of call does the above dances, so it seems easiest to
    call it rather than duplicate it by hand.

    2026-08-18  Jakub Jelinek  <[email protected]>

            PR c++/126867
            * tree.cc (record_has_unique_obj_representations): Use
            location_of (const_cast <tree> (t)) rather than
            DECL_SOURCE_LOCATION (t).

            * g++.dg/cpp1z/has-unique-obj-representations6.C: New test.

    Reviewed-by: Jason Merrill <[email protected]>
    (cherry picked from commit 318e6a4640420d5cc213df779bf751485fa56063)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.