[Bug c++/43947] New: [C++0x] constexpr should allow declaration without a definition
public at alisdairm dot net
gcc-bugzilla@gcc.gnu.org
Fri Apr 30 12:16:00 GMT 2010
GCC 4.5 has early support for constexpr, which syntax checks code but does not
support use in a constant expression.
The following code should be allowed, but fails as GCC currently requires the
in initial declaration also be a definition:
constexpr auto five() -> int;
inline constexpr auto five() -> int { return 5; }
Similarly, member functions should be allowed:
struct host {
static constexpr auto five() -> int;
}
inline constexpr auto host::five() -> int { return 5; }
and finally constructors:
struct test_type {
int data;
constexpr test_type(int x);
};
inline constexpr test_type::test_type(int x )
: data{x}
{
}
Note that the constexpr keyword is required on *every* declaration and
definition.
--
Summary: [C++0x] constexpr should allow declaration without a
definition
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: public at alisdairm dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43947
More information about the Gcc-bugs
mailing list