[Bug c++/108099] [12/13 Regression] ICE with type alias with `signed __int128_t`

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Dec 14 18:18:04 GMT 2022


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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r12-8173-ge580f81d22d61153564959f08d9a6d3bcc7fd386
For
using u128 = unsigned __int128_t;
auto a = sizeof (u128);
it doesn't ICE but changes behavior, before that commit a was 16, now it is 4.
The reason for the ICE as well as 4 in there is because r12-8173 does:
+             type = DECL_ORIGINAL_TYPE (typedef_decl);
+             typedef_decl = NULL_TREE;
which is fine for user typedefs, but for the internally created typedefs like
__int128_t, __uint128_t, __builtin_va_list, dunno if others too
DECL_ORIGINAL_TYPE
is NULL.
So, the question is if we should fix it by tweaking c-common.cc so that instead
of say:
  if (targetm.scalar_mode_supported_p (TImode))
    lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
                                           TYPE_DECL,
                                           get_identifier ("__int128_t"),
                                           intTI_type_node));
do
  if (targetm.scalar_mode_supported_p (TImode))
    {
      tree decl = build_decl (UNKNOWN_LOCATION, TYPE_DECL,
                              get_identifier ("__int128_t"),
                              intTI_type_node);
      DECL_ORIGINAL_TYPE (decl) = intTI_type_node;
      lang_hooks.decls.pushdecl (decl);
    }
etc., or if it wouldn't be better or at least easier to:
--- gcc/cp/decl.cc.jj   2022-12-05 11:10:37.528674260 +0100
+++ gcc/cp/decl.cc      2022-12-14 19:16:40.242926374 +0100
@@ -12442,7 +12442,8 @@ grokdeclarator (const cp_declarator *dec
              pedwarn (loc, OPT_Wpedantic, "%qs specified with %qT",
                       key, type);
              ok = !flag_pedantic_errors;
-             type = DECL_ORIGINAL_TYPE (typedef_decl);
+             if (DECL_ORIGINAL_TYPE (typedef_decl))
+               type = DECL_ORIGINAL_TYPE (typedef_decl);
              typedef_decl = NULL_TREE;
            }
          else if (declspecs->decltype_p)
I'm going to test the latter.


More information about the Gcc-bugs mailing list