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

            Bug ID: 92024
           Summary: crash in check_local_shadow
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bernd.edlinger at hotmail dot de
  Target Milestone: ---

g++ crashes on testsuite/g++.dg/parse/crash68.C
when invoked with -Wshadow=compatible-local

$ g++ -Wshadow=compatible-local crash68.C 
crash68.C: In constructor 'a< <template-parameter-1-1> >::a()':
crash68.C:8:23: error: types may not be defined in exception-declarations
    8 |     } catch (struct c {}) {  // { dg-error "types may not be
defined|conflicting" }
      |                       ^
crash68.C: In instantiation of 'a< <template-parameter-1-1> >::a() [with
<template-parameter-1-1> = int]':
crash68.C:18:6:   required from here
crash68.C:8:24: error: conflicting declaration 'struct a<
<template-parameter-1-1> >::a() [with <template-parameter-1-1> = int]::c'
    8 |     } catch (struct c {}) {  // { dg-error "types may not be
defined|conflicting" }
      |                        ^
crash68.C:6:12: note: previous declaration as 'struct a<
<template-parameter-1-1> >::a() [with <template-parameter-1-1> = int]::c'
    6 |     struct c;
      |            ^
crash68.C:8:21: internal compiler error: Segmentation fault
    8 |     } catch (struct c {}) {  // { dg-error "types may not be
defined|conflicting" }
      |                     ^
0xeec04f crash_signal
        ../../gcc-10-20191006/gcc/toplev.c:326
0x9c3062 tree_check(tree_node*, char const*, int, char const*, tree_code)
        ../../gcc-10-20191006/gcc/tree.h:3266
0x9c3062 instantiate_class_template_1
        ../../gcc-10-20191006/gcc/cp/pt.c:10977
0x9c4db2 instantiate_class_template(tree_node*)
        ../../gcc-10-20191006/gcc/cp/pt.c:11525
0xa06559 complete_type(tree_node*)
        ../../gcc-10-20191006/gcc/cp/typeck.c:139
0x9d2798 lookup_base(tree_node*, tree_node*, int, base_kind*, int)
        ../../gcc-10-20191006/gcc/cp/search.c:194
0x84a93d is_properly_derived_from(tree_node*, tree_node*)
        ../../gcc-10-20191006/gcc/cp/call.c:10026
0x84a93d is_properly_derived_from(tree_node*, tree_node*)
        ../../gcc-10-20191006/gcc/cp/call.c:10018
0x84af82 standard_conversion
        ../../gcc-10-20191006/gcc/cp/call.c:1496
0x84da39 implicit_conversion
        ../../gcc-10-20191006/gcc/cp/call.c:1972
0x85ff58 can_convert_arg(tree_node*, tree_node*, tree_node*, int, int)
        ../../gcc-10-20191006/gcc/cp/call.c:11164
0x93108e check_local_shadow
        ../../gcc-10-20191006/gcc/cp/name-lookup.c:2762
0x93108e do_pushdecl
        ../../gcc-10-20191006/gcc/cp/name-lookup.c:3096
0x931813 pushdecl(tree_node*, bool)
        ../../gcc-10-20191006/gcc/cp/name-lookup.c:3161
0x931813 do_pushdecl_with_scope
        ../../gcc-10-20191006/gcc/cp/name-lookup.c:3843
0x931f61 do_pushtag
        ../../gcc-10-20191006/gcc/cp/name-lookup.c:6840
0x931f61 pushtag(tree_node*, tree_node*, tag_scope)
        ../../gcc-10-20191006/gcc/cp/name-lookup.c:6910
0x9b2991 lookup_template_class_1
        ../../gcc-10-20191006/gcc/cp/pt.c:9561
0x9b3c53 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
        ../../gcc-10-20191006/gcc/cp/pt.c:9775
0x9b3c53 tsubst_aggr_type
        ../../gcc-10-20191006/gcc/cp/pt.c:12777
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.


It is in this expression
      else if (warn_shadow_compatible_local
               && (same_type_p (TREE_TYPE (old), TREE_TYPE (decl))
                   || (!dependent_type_p (TREE_TYPE (decl))
                       && !dependent_type_p (TREE_TYPE (old))
                       /* If the new decl uses auto, we don't yet know
                          its type (the old type cannot be using auto
                          at this point, without also being
                          dependent).  This is an indication we're
                          (now) doing the shadow checking too
                          early.  */
                       && !type_uses_auto (TREE_TYPE (decl))
                       && can_convert (TREE_TYPE (old), TREE_TYPE (decl),
                                       tf_none))))

What is wrong with this can_convert?

Reply via email to