public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/43947]  New: [C++0x] constexpr should allow declaration without a definition
@ 2010-04-30 12:16 public at alisdairm dot net
  2010-04-30 12:56 ` [Bug c++/43947] " redi at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: public at alisdairm dot net @ 2010-04-30 12:16 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 6+ messages in thread
[parent not found: <bug-43947-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2011-03-17  0:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-30 12:16 [Bug c++/43947] New: [C++0x] constexpr should allow declaration without a definition public at alisdairm dot net
2010-04-30 12:56 ` [Bug c++/43947] " redi at gcc dot gnu dot org
2010-04-30 12:57 ` paolo dot carlini at oracle dot com
2010-04-30 13:16 ` public at alisdairm dot net
2010-04-30 15:42 ` paolo dot carlini at oracle dot com
     [not found] <bug-43947-4@http.gcc.gnu.org/bugzilla/>
2011-03-17  1:10 ` 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).