public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105553] New: Deduction when attempting to create an array with an element type that is an abstract class
@ 2022-05-10 18:36 glenjofe at gmail dot com
  2022-05-11  7:38 ` [Bug c++/105553] [11/12/13 Regression] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: glenjofe at gmail dot com @ 2022-05-10 18:36 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-16 21:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10 18:36 [Bug c++/105553] New: Deduction when attempting to create an array with an element type that is an abstract class glenjofe at gmail dot com
2022-05-11  7:38 ` [Bug c++/105553] [11/12/13 Regression] " rguenth at gcc dot gnu.org
2022-05-16 16:44 ` [Bug c++/105553] [11/12/13 Regression] [DR1640] " jason at gcc dot gnu.org
2022-05-16 16:46 ` jason at gcc dot gnu.org
2022-05-16 21:14 ` glenjofe at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).