http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51305

             Bug #: 51305
           Summary: [C++11][constexpr] noexcept-specifier overconstraints
                    constexpr functions
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: daniel.krueg...@googlemail.com
                CC: ja...@gcc.gnu.org


gcc 4.7.0 20111119 (experimental) in C++11 mode with -Wall rejects the
following code:

//-------
constexpr bool ok() noexcept
{
  typedef int type;
  return true;
}

constexpr auto x = ok();
//-------

the error being:

"
main.cpp||In function 'constexpr bool ok()':|
main.cpp|5|error: body of constexpr function 'constexpr bool ok()' not a
return-statement|
main.cpp|7|error: 'constexpr bool ok()' called in a constant expression
"

The stringency becomes activated with the addition of the noexcept-specifier to
the constexpr function.

Here is a more advanced test set that should be accepted after the fix of this
issue:

//-------
namespace n { void foo(); }

constexpr bool ok() noexcept
{
  typedef bool some;
  using other = int;
  using namespace n;
  using n::foo;
  ;
  static_assert(!false, "");
  return true;
}

constexpr auto x = ok();

template<bool>
struct C{};

C<ok()> c;
//-------

Reply via email to