public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107439] New: use of static member function in requires-expression depends on declaration order
@ 2022-10-27 16:22 jwjagersma at gmail dot com
  2022-10-28 14:01 ` [Bug c++/107439] " ppalka at gcc dot gnu.org
  2022-10-28 14:27 ` ppalka at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: jwjagersma at gmail dot com @ 2022-10-27 16:22 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107439
           Summary: use of static member function in requires-expression
                    depends on declaration order
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jwjagersma at gmail dot com
  Target Milestone: ---

The following example fails to compile, as g++ complains that a declaration of
'check' is not available.  Reordering it so that 'check' is declared before
its use in the requires-expression makes it work.  This seems inconsistent, as
member functions are normally expected to be usable anywhere within the class
definition.

  $ cat requires-memfn.cpp
  struct A
  {
    template<typename T> requires (check<T>())
    auto func(T) { }

    template<typename T>
    static consteval bool check() { return true; }
  };

  $ g++ -std=c++20 requires-memfn.cpp
  requires-memfn.cpp:3:34: error: there are no arguments to ‘check’ that depend
on a template parameter, so a declaration of ‘check’
   must be available [-fpermissive]
      3 |   template<typename T> requires (check<T>())
        |                                  ^~~~~~~~
  requires-memfn.cpp:3:34: note: (if you use ‘-fpermissive’, G++ will accept
your code, but allowing the use of an undeclared name is deprecated)

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

end of thread, other threads:[~2022-10-28 14:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-27 16:22 [Bug c++/107439] New: use of static member function in requires-expression depends on declaration order jwjagersma at gmail dot com
2022-10-28 14:01 ` [Bug c++/107439] " ppalka at gcc dot gnu.org
2022-10-28 14:27 ` 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).