Bug 49332 - [C++11/14 only] noexcept ignored on function pointer
Summary: [C++11/14 only] noexcept ignored on function pointer
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid, rejects-valid
: 103092 (view as bug list)
Depends on: 12255
Blocks:
  Show dependency treegraph
 
Reported: 2011-06-08 21:45 UTC by Jason Merrill
Modified: 2021-12-20 04:41 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-06-08 21:47:18


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Merrill 2011-06-08 21:45:39 UTC
This testcase should give an error on the initialization and no error on the static_assert.

// { dg-options -std=c++0x }                                                                   

void f();
void (*p)() noexcept = f; // { dg-error "" }                                             

#define SA(X) static_assert((X),#X)

SA(noexcept(p()));

The underlying issue is PR 12255, but while this behavior was not observable in C++98, it is observable in C++0x.
Comment 1 Jason Merrill 2011-06-08 21:47:04 UTC
Or rather in C++98 it was observable through diagnostics, but couldn't change the behavior of a well-defined program.
Comment 2 Marek Polacek 2019-06-21 16:53:37 UTC
This still compiles without errors in C++11, but in C++17:

49332.C:4:24: error: invalid conversion from ‘void (*)()’ to ‘void (*)() noexcept’ [-fpermissive]
    4 | void (*p)() noexcept = f; // { dg-error "" }
      |                        ^
      |                        |
      |                        void (*)()
Comment 3 Andrew Pinski 2021-11-06 04:55:26 UTC
*** Bug 103092 has been marked as a duplicate of this bug. ***