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

* [Bug c++/105553] [11/12/13 Regression] Deduction when attempting to create an array with an element type that is an abstract class
  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 ` 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
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-11  7:38 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Deduction when attempting   |[11/12/13 Regression]
                   |to create an array with an  |Deduction when attempting
                   |element type that is an     |to create an array with an
                   |abstract class              |element type that is an
                   |                            |abstract class
   Target Milestone|---                         |11.4
           Keywords|                            |rejects-valid

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

* [Bug c++/105553] [11/12/13 Regression] [DR1640] Deduction when attempting to create an array with an element type that is an abstract class
  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 ` 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
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2022-05-16 16:44 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[11/12/13 Regression]       |[11/12/13 Regression]
                   |Deduction when attempting   |[DR1640] Deduction when
                   |to create an array with an  |attempting to create an
                   |element type that is an     |array with an element type
                   |abstract class              |that is an abstract class
         Resolution|---                         |INVALID
                 CC|                            |jason at gcc dot gnu.org
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> ---
That wording was removed by wg21.link/p0929r2 to address wg21.link/cwg1640 ,
which is about this exact pattern.

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

* [Bug c++/105553] [11/12/13 Regression] [DR1640] Deduction when attempting to create an array with an element type that is an abstract class
  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
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2022-05-16 16:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
I implemented P0929R2 in r11-5036.

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

* [Bug c++/105553] [11/12/13 Regression] [DR1640] Deduction when attempting to create an array with an element type that is an abstract class
  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
                   ` (2 preceding siblings ...)
  2022-05-16 16:46 ` jason at gcc dot gnu.org
@ 2022-05-16 21:14 ` glenjofe at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: glenjofe at gmail dot com @ 2022-05-16 21:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Glen Joseph Fernandes <glenjofe at gmail dot com> ---
I would have expected this to only take effect in C++20 standards mode, leaving
C++03 through C++17 modes with no change in behavior.

Given the following intention in your commit message:

> This change was moved as a DR, so I'm applying it to all
standard levels.  This could be reconsidered if it causes problems, but I
don't expect it to.

I'm going to assume that in general this wasn't a problem for most users. :)

^ 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).