public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95175] New: constexpr and alias template
@ 2020-05-17 15:57 nina.didenko at gmail dot com
  2020-05-18 23:45 ` [Bug c++/95175] [9/10/11 Regression] " mpolacek at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: nina.didenko at gmail dot com @ 2020-05-17 15:57 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95175
           Summary: constexpr and alias template
           Product: gcc
           Version: 9.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nina.didenko at gmail dot com
  Target Milestone: ---

This snippet successfully compiles using gcc6 up to gcc8.
When building using gcc 9.3.0 there is an error

template<typename R, typename... Types>
using Function = R(*)(Types...);

struct Struct
{
  void *addr;

  template<typename R, typename... Types>
  constexpr Struct(Function<R, Types...> addr) : addr((void*)(addr)) {}
};

void TestFunction()
{
}

int main(void)
{
  static constexpr Struct functions[]{
    {TestFunction},
  };
}

The error is

4.cpp: In function 'int main()':
4.cpp:20:3: error: 'constexpr Struct::Struct(Function<R, Types ...>) [with R =
void; Types = {}; Function<R, Types ...> = void (*)()]' called in a constant
expression
   20 |   };
      |   ^
4.cpp:9:13: note: 'constexpr Struct::Struct(Function<R, Types ...>) [with R =
void; Types = {}; Function<R, Types ...> = void (*)()]' is not usable as a
'constexpr' function because:
    9 |   constexpr Struct(Function<R, Types...> addr) : addr((void*)(addr)) {}

The full product code

https://github.com/TES3MP/openmw-tes3mp/blob/0.7.1/apps/openmw-mp/Script/ScriptFunctions.hpp#L120
https://github.com/TES3MP/openmw-tes3mp/blob/0.7.1/apps/openmw-mp/Script/Types.hpp#L99

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

end of thread, other threads:[~2020-06-03 19:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-17 15:57 [Bug c++/95175] New: constexpr and alias template nina.didenko at gmail dot com
2020-05-18 23:45 ` [Bug c++/95175] [9/10/11 Regression] " mpolacek at gcc dot gnu.org
2020-05-27 18:14 ` jason at gcc dot gnu.org
2020-06-03 19:39 ` jason 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).