On Wednesday, 28 January 2015 at 09:33:00 UTC, Johannes Pfau
wrote:
Am Wed, 28 Jan 2015 07:55:34 +0000
schrieb "simendsjo" <simend...@gmail.com>:
(...)
I registered an account on https://gcc.gnu.org/bugzilla some
time ago
and there were no restrictions. Sounds like they currently have
some issues with their email servers.
In that case they've had the problems for a week. Is there
someone that can be contacted about this? Maybe they don't know
about the problem? The mail address that comes up at bugzilla
isn't in use.
If not, maybe you can add the issue?
The bugreport is pasted below.
====
Hi,
The following short example is a (somewhat reduced) example from
Bjarne Stroustroups book Programming Principles and Practice using
C++ 2nd edition first print, section 8.5.9 on page 290.
I'm able to reproduce the behavior on shorter examples, but I'm
afraid to do so as I don't know enough C++ to know if I'm hiding
the actual error.
After mailing Stroustrup about the issue, he suggested I added
a bug report. I'm unable to register at Bugzilla, so I add it here
in a hope that someone with access can add it.
He noted that I should copy the following text in the bugreport:
12.8 Copying and moving class objects [class.copy]
A copy/move constructor that is defaulted and not defined as
deleted is implicitly defined if it is odrused (3.2) or when
it is explicitly defaulted after its first declaration.
[ Note: The copy/move constructor is implicitly defined even
if the implementation elided its odr-use (3.2, 12.2). —end
note ] If the implicitlydefined constructor would satisfy
the requirements of a constexpr constructor (7.1.5), the
implicitly-defined constructor is constexpr.
----
The code in question that fails to compile (a bit reduced from the
book example):
struct Point { double x, y; };
constexpr double xscale = 10;
constexpr double yscale = 0.8;
constexpr Point scale(Point p) { return
{xscale*p.x,yscale*p.y};}
int main() {
Point p2 {10,10};
constexpr Point p6 = scale(p2); // Error 'p2 not usable
in constant expression'
}
----
The compiler arguments used and the error it produces:
$ g++ -std=c++11 -c -o test.o test.cpp
test.cpp: In function ‘int main()’:
test.cpp:10:34: error: the value of ‘p2’ is not usable in a
constant expression
constexpr Point p6 = scale(p2); // Error 'p2 not usable
in constant expression'
^
test.cpp:9:11: note: ‘p2’ was not declared ‘constexpr’
Point p2 {10,10};
^
----
Versions used:
$ gcc --version
gcc (GCC) 4.9.2 20141224 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
$ g++ --version
g++ (GCC) 4.9.2 20141224 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
$ uname -a
Linux simendsjo-desktop 3.16.6-1-ck-bamboo #1 SMP PREEMPT Mon
Jan 5 20:15:19 CET 2015 x86_64 GNU/Linux
Let me know if you need more information in order to reproduce
this.
/simendsjo