public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107179] New: requires-expression gives hard error for inaccessible constructor
@ 2022-10-07 11:53 redi at gcc dot gnu.org
  2022-10-07 13:19 ` [Bug c++/107179] [11/12/13 Regression] " ppalka at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2022-10-07 11:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107179
           Summary: requires-expression gives hard error for inaccessible
                    constructor
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

template<bool B> struct bool_constant { static constexpr bool value = B; };

template<typename T>
  struct is_implicitly_default_constructible
  : bool_constant<requires (void (*f)(const T&)) { f({}); }>
  { };

class X {
  X();
public:
  X(int);
};

static_assert( !is_implicitly_default_constructible<X>::value );


This should compile with -std=c++20 but doesn't:

conv.cc: In instantiation of 'struct is_implicitly_default_constructible<X>':
conv.cc:14:55:   required from here
conv.cc:5:53: error: 'X::X()' is private within this context
    5 |   : bool_constant<requires (void (*f)(const T&)) { f({}); }>
      |                                                    ~^~~~
conv.cc:9:3: note: declared private here
    9 |   X();
      |   ^
conv.cc:14:16: error: static assertion failed
   14 | static_assert( !is_implicitly_default_constructible<X>::value );
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

end of thread, other threads:[~2023-05-22  3:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-07 11:53 [Bug c++/107179] New: requires-expression gives hard error for inaccessible constructor redi at gcc dot gnu.org
2022-10-07 13:19 ` [Bug c++/107179] [11/12/13 Regression] " ppalka at gcc dot gnu.org
2022-10-18  8:34 ` rguenth at gcc dot gnu.org
2022-11-03 19:36 ` cvs-commit at gcc dot gnu.org
2023-03-07  2:18 ` [Bug c++/107179] [11/12 " cvs-commit at gcc dot gnu.org
2023-05-22  3:12 ` [Bug c++/107179] [11 " cvs-commit at gcc dot gnu.org
2023-05-22  3:14 ` ppalka at gcc dot gnu.org

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