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

            Bug ID: 118201
           Summary: ICE: in maybe_explain_implicit_delete, at
                    cp/method.cc:3143
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wangbopku15 at gmail dot com
  Target Milestone: ---

Extended from official test:
https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/g%2B%2B.old-deja/g%2B%2B.pt/mi1.C.

When the dtors of some of the classes are set defaulted, the ICE appears.

Please see https://godbolt.org/z/K7WYb4rda

Input test:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

class PK_CryptoSystem
{
};
class PK_Encryptor : public virtual PK_CryptoSystem
{
};
class PK_FixedLengthCryptoSystem : public virtual PK_CryptoSystem
{
public:
        virtual unsigned int CipherTextLength() const =0;
};
class PK_FixedLengthEncryptor : public virtual PK_Encryptor, public virtual
PK_FixedLengthCryptoSystem
{

};
class PK_SignatureSystem
{
public:
        virtual ~PK_SignatureSystem() {}
};
class PK_Signer : public virtual PK_SignatureSystem
{
public:
        virtual void Sign() = 0;
};
class PK_Verifier : public virtual PK_SignatureSystem
{
};
class PK_Precomputation
{
   ~PK_Precomputation()=default;
};
template <class T> class
PK_WithPrecomputation : public T, public virtual PK_Precomputation
{
    ~PK_WithPrecomputation()=default;
};
typedef PK_WithPrecomputation<PK_FixedLengthEncryptor> PKWPFLE;
typedef PK_WithPrecomputation<PK_Signer> PKWPS;
template <class EC> class
ECPublicKey : public PKWPFLE
{
public:
        unsigned int CipherTextLength() const { return 1; }
        EC ec;
    ~ECPublicKey()=default;
};
template <class EC>
class ECPrivateKey : public ECPublicKey<EC>, public PKWPS
{
        void Sign() {}
        int d;
    ~ECPrivateKey()=default;
};
template <class EC>
class ECKEP : public ECPrivateKey<EC>
{
};
class GF2NT : public PK_CryptoSystem
{
        int t1;
    ~GF2NT()=default;
};
class EC2N : public PK_CryptoSystem
{
        GF2NT field;
        int a;
    ~EC2N()=default;
};
template class ECKEP<EC2N>;

int
main ()
{
  ECKEP<EC2N> foo;

  return 0;
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Compiler Output:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

<source>: In instantiation of 'class ECPrivateKey<EC2N>':
<source>:56:7:   required from 'class ECKEP<EC2N>'
   56 | class ECKEP : public ECPrivateKey<EC>
      |       ^~~~~
<source>:70:16:   required from here
   70 | template class ECKEP<EC2N>;
      |                ^~~~~~~~~~~
<source>:53:5: error: non-deleted function 'ECPrivateKey<EC>::~ECPrivateKey()
[with EC = EC2N]' overriding deleted function
   53 |     ~ECPrivateKey()=default;
      |     ^
<source>:36:5: note: overridden function is
'PK_WithPrecomputation<T>::~PK_WithPrecomputation() [with T = PK_Signer]'
   36 |     ~PK_WithPrecomputation()=default;
      |     ^
<source>: In function 'int main()':
<source>:75:15: error: use of deleted function 'ECKEP<EC2N>::ECKEP()'
   75 |   ECKEP<EC2N> foo;
      |               ^~~
<source>:56:7: note: 'ECKEP<EC2N>::ECKEP()' is implicitly deleted because the
default definition would be ill-formed:
   56 | class ECKEP : public ECPrivateKey<EC>
      |       ^~~~~
<source>: At global scope:
<source>:56:7: error: use of deleted function
'ECPrivateKey<EC2N>::ECPrivateKey()'
<source>:49:7: note: 'ECPrivateKey<EC2N>::ECPrivateKey()' is implicitly deleted
because the default definition would be ill-formed:
   49 | class ECPrivateKey : public ECPublicKey<EC>, public PKWPS
      |       ^~~~~~~~~~~~
<source>:49:7: error: use of deleted function
'ECPublicKey<EC2N>::ECPublicKey()'
<source>:41:1: note: 'ECPublicKey<EC2N>::ECPublicKey()' is implicitly deleted
because the default definition would be ill-formed:
   41 | ECPublicKey : public PKWPFLE
      | ^~~~~~~~~~~
<source>:41:1: error: use of deleted function
'PK_WithPrecomputation<T>::~PK_WithPrecomputation() [with T =
PK_FixedLengthEncryptor]'
<source>:36:5: note: 'PK_WithPrecomputation<T>::~PK_WithPrecomputation()
noexcept (<uninstantiated>) [with T = PK_FixedLengthEncryptor]' is implicitly
deleted because its exception-specification does not match the implicit
exception-specification 'noexcept'
   36 |     ~PK_WithPrecomputation()=default;
      |     ^
<source>:41:1: error: use of deleted function 'EC2N::EC2N()'
   41 | ECPublicKey : public PKWPFLE
      | ^~~~~~~~~~~
<source>:64:7: note: 'EC2N::EC2N()' is implicitly deleted because the default
definition would be ill-formed:
   64 | class EC2N : public PK_CryptoSystem
      |       ^~~~
<source>:64:7: error: 'GF2NT::~GF2NT()' is private within this context
<source>:62:5: note: declared private here
   62 |     ~GF2NT()=default;
      |     ^
<source>:41:1: note: use '-fdiagnostics-all-candidates' to display considered
candidates
   41 | ECPublicKey : public PKWPFLE
      | ^~~~~~~~~~~
<source>:41:1: error: use of deleted function 'EC2N::~EC2N()'
<source>:68:5: note: 'EC2N::~EC2N()' is implicitly deleted because the default
definition would be ill-formed:
   68 |     ~EC2N()=default;
      |     ^
<source>:68:5: error: 'GF2NT::~GF2NT()' is private within this context
<source>:62:5: note: declared private here
   62 |     ~GF2NT()=default;
      |     ^
<source>:49:7: note: use '-fdiagnostics-all-candidates' to display considered
candidates
   49 | class ECPrivateKey : public ECPublicKey<EC>, public PKWPS
      |       ^~~~~~~~~~~~
<source>:49:7: error: use of deleted function 'ECPublicKey<EC>::~ECPublicKey()
[with EC = EC2N]'
<source>:46:5: note: 'ECPublicKey<EC>::~ECPublicKey() [with EC = EC2N]' is
implicitly deleted because the default definition would be ill-formed:
   46 |     ~ECPublicKey()=default;
      |     ^
<source>:46:5: error: use of deleted function
'PK_WithPrecomputation<T>::~PK_WithPrecomputation() [with T =
PK_FixedLengthEncryptor]'
<source>:46:5: error: 'PK_Precomputation::~PK_Precomputation()' is private
within this context
<source>:31:4: note: declared private here
   31 |    ~PK_Precomputation()=default;
      |    ^
<source>:46:5: error: use of deleted function 'EC2N::~EC2N()'
   46 |     ~ECPublicKey()=default;
      |     ^
<source>:49:7: error: use of deleted function
'PK_WithPrecomputation<T>::~PK_WithPrecomputation() [with T = PK_Signer]'
   49 | class ECPrivateKey : public ECPublicKey<EC>, public PKWPS
      |       ^~~~~~~~~~~~
<source>:36:5: internal compiler error: in maybe_explain_implicit_delete, at
cp/method.cc:3143
   36 |     ~PK_WithPrecomputation()=default;
      |     ^
0x2938075 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
        ???:0
0x294ee76 internal_error(char const*, ...)
        ???:0
0xacaf50 fancy_abort(char const*, int, char const*)
        ???:0
0xbcf937 mark_used(tree_node*, int)
        ???:0
0xaeba53 build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, tree_node*, int, tree_node**, int)
        ???:0
0xc25ee9 maybe_explain_implicit_delete(tree_node*)
        ???:0
0xbcf937 mark_used(tree_node*, int)
        ???:0
0xaeba53 build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, tree_node*, int, tree_node**, int)
        ???:0
0xc25ee9 maybe_explain_implicit_delete(tree_node*)
        ???:0
0xbcf937 mark_used(tree_node*, int)
        ???:0
0xaeba53 build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, tree_node*, int, tree_node**, int)
        ???:0
0xaecdad build_special_member_call(tree_node*, tree_node*, vec<tree_node*,
va_gc, vl_embed>**, tree_node*, int, int)
        ???:0
0xbf562a build_aggr_init(tree_node*, tree_node*, int, int)
        ???:0
0xbc037e cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int,
cp_decomp*)
        ???:0
0xce5603 c_parse_file()
        ???:0
0xe450d9 c_common_parse_file()
        ???:0
Please submit a full bug report, with preprocessed source .
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reply via email to