Bug 88368 - [8 Regression] Improper ``use of deleted function''
Summary: [8 Regression] Improper ``use of deleted function''
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.2.1
: P2 normal
Target Milestone: 9.0
Assignee: Jason Merrill
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2018-12-05 13:44 UTC by serge.guelton
Modified: 2021-05-14 11:14 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2019-02-12 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description serge.guelton 2018-12-05 13:44:27 UTC
The following code fails to compile: https://godbolt.org/z/briQXa
Adding a `noexcept` specifier to the default constructor fixes the issue, but it shouldn't be needed..

Clang compiles this code correctly, so does gcc 4.9. But gcc 7.3 doesn't, for another reason.
Comment 1 Jakub Jelinek 2018-12-05 13:47:59 UTC
#include <type_traits>
#include <utility>

template<class T>
union trivial_helper {
    T t;
};

template <typename T>
struct trait {
  static constexpr bool value = std::is_copy_constructible<trivial_helper<T>>::value;
};

struct BlockFrequencyInfoImplBase {

  struct BlockNode {
    int Index = 1;
    BlockNode() = default;
  };

  static constexpr bool v = trait<std::pair<BlockNode, int>>::value; // << remove this line to remove the error

  void print() const {
    BlockNode BB;
  }
};

Testcase included inline.  Used to be rejected e.g. in r210000, from r216750 and before r250994 used to be rejected with a different error.
Comment 2 Jakub Jelinek 2018-12-05 13:58:05 UTC
r209907 is the first one that rejects it this way, before that the preprocessed source I'm trying doesn't compile because of some __is_trivially_assignable changes, so it is possible 4.9 accepted this with 4.9 headers.
Comment 3 Jonathan Wakely 2018-12-05 14:32:39 UTC
Yes, 4.9 accepts it, but so does 5.5 which contains r209907
Comment 4 Jason Merrill 2019-02-20 02:01:39 UTC
Author: jason
Date: Wed Feb 20 02:00:29 2019
New Revision: 269032

URL: https://gcc.gnu.org/viewcvs?rev=269032&root=gcc&view=rev
Log:
	PR c++/88368 - wrong 'use of deleted function'

Since my patch for 81359 allowed us to signal failure on return from
maybe_instantiate_noexcept, we no longer need to turn an error into
noexcept(false).  We also need to handle NSDMI instantiation errors under
synthesized_method_walk.  This change caused some instantiation context
notes to be lost in the testsuite, so I added push_tinst_level to
get_defaulted_eh_spec to restore that context.

	* method.c (walk_field_subobs): Remember errors from get_nsdmi.
	(get_defaulted_eh_spec): Call push_tinst_level.
	* pt.c (maybe_instantiate_noexcept): Keep error_mark_node.
	* typeck2.c (merge_exception_specifiers): Handle error_mark_node.

Added:
    trunk/gcc/testsuite/g++.dg/ext/is_constructible3.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/method.c
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/typeck2.c
    trunk/gcc/testsuite/g++.dg/cpp0x/nsdmi3.C
Comment 5 Jason Merrill 2019-02-20 02:02:40 UTC
Fixed on trunk so far.
Comment 6 Jakub Jelinek 2019-03-04 10:21:15 UTC
The above change introduced PR89571.
Comment 7 Richard Biener 2019-11-14 07:56:16 UTC
The GCC 7 branch is being closed, re-targeting to GCC 8.4.
Comment 8 Jakub Jelinek 2020-03-04 09:37:41 UTC
GCC 8.4.0 has been released, adjusting target milestone.
Comment 9 Jakub Jelinek 2021-05-14 11:14:54 UTC
The GCC 8 branch is being closed, fixed in GCC 9.1.