public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/60511] New: [C++1y][N3652] Missing extended constexpr function support
@ 2014-03-12 18:53 daniel.kruegler at googlemail dot com
2014-12-14 0:36 ` [Bug c++/60511] " ville.voutilainen at gmail dot com
2014-12-15 15:26 ` jason at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2014-03-12 18:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60511
Bug ID: 60511
Summary: [C++1y][N3652] Missing extended constexpr function
support
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: daniel.kruegler at googlemail dot com
gcc 4.9.0 20140309 (experimental) compiled with the flags
-std=c++1y -Wall -pedantic
rejects:
//----------------------
template<class T>
struct L
{
T t;
constexpr L(const T& t) : t(t) {}
constexpr const T& value() const & { return t; }
constexpr T& value() & { return t; }
};
template<class T>
constexpr T twice(const T& t) {
L<T> l(t);
l.value() *= 2;
return l.value();
}
int main() {
constexpr int i = twice(12);
static_assert(i == 24, "");
}
//----------------------
<quote>
prog.cc:7:16: error: 'constexpr T& L<T>::value() const &' cannot be overloaded
constexpr T& value() & { return t; }
^
prog.cc:6:22: error: with 'constexpr const T& L<T>::value() const &'
constexpr const T& value() const & { return t; } ^
prog.cc: In instantiation of 'constexpr T twice(const T&) [with T = int]':
prog.cc:18:29: required from here
prog.cc:13:13: error: assignment of read-only location 'l.L<T>::value<int>()'
l.value() *= 2;
^
prog.cc:15:1: error: body of constexpr function 'constexpr T twice(const T&)
[with T =
int]' not a return-statement
}
^
prog.cc: In function 'int main()':
prog.cc:18:29: error: 'constexpr T twice(const T&) [with T = int]' called in a
constant expression
constexpr int i = twice(12);
^
prog.cc:11:13: note: 'constexpr T twice(const T&) [with T = int]' is not usable
as
a constexpr function because:
constexpr T twice(const T& t) {
^
</quote>
The compiler seems currently not apply the extended C++14 constexpr rules as of
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3652.html
1) constexpr makes non-static member functions automatically const member
functions
2) constexpr functions require a single return statement
3) constexpr functions reject mutable operations
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/60511] [C++1y][N3652] Missing extended constexpr function support
2014-03-12 18:53 [Bug c++/60511] New: [C++1y][N3652] Missing extended constexpr function support daniel.kruegler at googlemail dot com
@ 2014-12-14 0:36 ` ville.voutilainen at gmail dot com
2014-12-15 15:26 ` jason at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: ville.voutilainen at gmail dot com @ 2014-12-14 0:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60511
Ville Voutilainen <ville.voutilainen at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at redhat dot com,
| |ville.voutilainen at gmail dot com
Known to work| |5.0
--- Comment #1 from Ville Voutilainen <ville.voutilainen at gmail dot com> ---
The current trunk accepts the testcase (and implements C++14 relaxed
constexpr). Shouldn't this be closed?
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/60511] [C++1y][N3652] Missing extended constexpr function support
2014-03-12 18:53 [Bug c++/60511] New: [C++1y][N3652] Missing extended constexpr function support daniel.kruegler at googlemail dot com
2014-12-14 0:36 ` [Bug c++/60511] " ville.voutilainen at gmail dot com
@ 2014-12-15 15:26 ` jason at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: jason at gcc dot gnu.org @ 2014-12-15 15:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60511
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |jason at gcc dot gnu.org
Resolution|--- |FIXED
Target Milestone|--- |5.0
--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
Implemented for GCC 5.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-12-15 15:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-12 18:53 [Bug c++/60511] New: [C++1y][N3652] Missing extended constexpr function support daniel.kruegler at googlemail dot com
2014-12-14 0:36 ` [Bug c++/60511] " ville.voutilainen at gmail dot com
2014-12-15 15:26 ` 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).