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

            Bug ID: 105553
           Summary: Deduction when attempting to create an array with an
                    element type that is an abstract class
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: glenjofe at gmail dot com
  Target Milestone: ---

Starting with GCC11, the following definition of a trait to check if a type is
abstract no longer works in any standard mode:

template<class T>
class is_abstract {
    template<class U>
    static char (&check(U(*)[1]))[2];
    template<class U>
    static char check(...);
public:
    static const bool value = sizeof(check<T>(0)) == sizeof(char);
};
struct abstract {
    virtual void function() = 0;
};
static_assert(is_abstract<abstract>::value, "ok");

The static assertion trigger on GCC11 and above, even in older standard modes.
It compiles fine on GCC10 and below.

Various libraries in Boost use the above definition of is_abstract especially
in C++03. The basis was the following wording in [temp.deduct] until C++17:

"Type deduction may fail for the following reasons:
- Attempting to create an array with an element type that is void, a function
type, a reference type, or an abstract class type, or attempting to create an
array with a size that is zero or negative."

The "or an abstract class type" was absent in C++03, added by CWG337.

Reply via email to