public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51305] New: [C++11][constexpr] noexcept-specifier overconstraints constexpr functions
@ 2011-11-25 17:45 daniel.kruegler at googlemail dot com
  2011-11-25 20:19 ` [Bug c++/51305] " paolo.carlini at oracle dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-11-25 17:45 UTC (permalink / raw)
  To: gcc-bugs

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: unassigned@gcc.gnu.org
        ReportedBy: daniel.kruegler@googlemail.com
                CC: jason@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;
//-------


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

end of thread, other threads:[~2011-12-21 16:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-25 17:45 [Bug c++/51305] New: [C++11][constexpr] noexcept-specifier overconstraints constexpr functions daniel.kruegler at googlemail dot com
2011-11-25 20:19 ` [Bug c++/51305] " paolo.carlini at oracle dot com
2011-12-21  1:23 ` paolo.carlini at oracle dot com
2011-12-21 16:30 ` paolo.carlini at oracle dot com
2011-12-21 16:38 ` paolo 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).