[Bug libstdc++/54025] atomicchrono::duration won't compile: chrono::duration::duration() is not C++11 compliant

2012-07-20 Thread paolo at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54025

--- Comment #15 from paolo at gcc dot gnu.org paolo at gcc dot gnu.org 
2012-07-20 09:49:02 UTC ---
Author: paolo
Date: Fri Jul 20 09:48:57 2012
New Revision: 189711

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=189711
Log:
2012-07-20  Chip Salzenberg  c...@pobox.com
Jonathan Wakely  jwakely@gmail.com

PR libstdc++/54025
* include/std/chrono (duration::duration): Fix per C++11.
* testsuite/20_util/duration/cons/54025.cc: New.
* testsuite/20_util/duration/cons/constexpr.cc: Adjust.

Added:
trunk/libstdc++-v3/testsuite/20_util/duration/cons/54025.cc
Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/std/chrono
trunk/libstdc++-v3/testsuite/20_util/duration/cons/constexpr.cc


[Bug libstdc++/54025] atomicchrono::duration won't compile: chrono::duration::duration() is not C++11 compliant

2012-07-20 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54025

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
Version|4.7.1   |4.8.0
 Resolution||FIXED
 AssignedTo|paolo.carlini at oracle dot |unassigned at gcc dot
   |com |gnu.org

--- Comment #16 from Paolo Carlini paolo.carlini at oracle dot com 2012-07-20 
09:51:39 UTC ---
Done.


[Bug libstdc++/54025] atomicchrono::duration won't compile: chrono::duration::duration() is not C++11 compliant

2012-07-19 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54025

Jonathan Wakely redi at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords||rejects-valid
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2012-07-19
 Ever Confirmed|0   |1

--- Comment #2 from Jonathan Wakely redi at gcc dot gnu.org 2012-07-19 
08:34:03 UTC ---
confirmed


[Bug libstdc++/54025] atomicchrono::duration won't compile: chrono::duration::duration() is not C++11 compliant

2012-07-19 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54025

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

 CC||redi at gcc dot gnu.org

--- Comment #3 from Paolo Carlini paolo.carlini at oracle dot com 2012-07-19 
09:40:07 UTC ---
Jon, shall I just apply patch and testcase?


[Bug libstdc++/54025] atomicchrono::duration won't compile: chrono::duration::duration() is not C++11 compliant

2012-07-19 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54025

--- Comment #4 from Jonathan Wakely redi at gcc dot gnu.org 2012-07-19 
10:20:07 UTC ---
Yes, I think so.  I initially wondered if there was some interaction with PR
53901 but I think that just makes the bug visible, duration's constructor
should be explicitly-defaulted anyway.


[Bug libstdc++/54025] atomicchrono::duration won't compile: chrono::duration::duration() is not C++11 compliant

2012-07-19 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54025

--- Comment #5 from Paolo Carlini paolo.carlini at oracle dot com 2012-07-19 
11:57:04 UTC ---
If we just do the change and nothing else, 20_util/duration/cons/constexpr.cc
doesn't compile anymore with this error:

/scratch/Gcc/svn-dirs/trunk/libstdc++-v3/testsuite/20_util/duration/cons/constexpr.cc:27:42:
  required from here
/scratch/Gcc/svn-dirs/trunk/libstdc++-v3/testsuite/util/testsuite_common_types.h:698:18:
error: uninitialized const '__obj' [-fpermissive]
  { constexpr _Tp __obj; }
  ^
In file included from
/scratch/Gcc/svn-dirs/trunk/libstdc++-v3/testsuite/20_util/duration/cons/constexpr.cc:21:0:
/home/paolo/Gcc/svn-dirs/trunk-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/chrono:220:14:
note: 'const struct std::chrono::durationlong int' has no user-provided
default constructor
   struct duration
  ^
/home/paolo/Gcc/svn-dirs/trunk-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/chrono:231:12:
note: constructor is not user-provided because it is explicitly defaulted in
the class body
  constexpr duration() = default;
^
/home/paolo/Gcc/svn-dirs/trunk-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/chrono:349:6:
note: and the implicitly-defined constructor does not initialize
'std::chrono::durationlong int::rep std::chrono::durationlong int::__r'
  rep __r;
  ^


[Bug libstdc++/54025] atomicchrono::duration won't compile: chrono::duration::duration() is not C++11 compliant

2012-07-19 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54025

--- Comment #6 from Jonathan Wakely redi at gcc dot gnu.org 2012-07-19 
12:06:32 UTC ---
I think that test is wrong, a duration is only constexpr_default_constructible
if the rep type has a default-constructor, but std::chrono::seconds uses a
scalar rep.

I think the test should use something like this to check duration is
constexpr-default-constructible:

struct Seconds {
constexpr Seconds() = default;
std::chrono::seconds s{};
};
test1.operator()std::chrono::durationSeconds();


[Bug libstdc++/54025] atomicchrono::duration won't compile: chrono::duration::duration() is not C++11 compliant

2012-07-19 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54025

--- Comment #7 from Jonathan Wakely redi at gcc dot gnu.org 2012-07-19 
12:08:29 UTC ---
(In reply to comment #6)
 I think that test is wrong, a duration is only constexpr_default_constructible
 if the rep type has a default-constructor

... that initializes all its members.


[Bug libstdc++/54025] atomicchrono::duration won't compile: chrono::duration::duration() is not C++11 compliant

2012-07-19 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54025

--- Comment #8 from Paolo Carlini paolo.carlini at oracle dot com 2012-07-19 
12:17:13 UTC ---
Understood, thanks. A couple of times in the past I already tweeked a bit some
of those tests. Let me see...


[Bug libstdc++/54025] atomicchrono::duration won't compile: chrono::duration::duration() is not C++11 compliant

2012-07-19 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54025

--- Comment #9 from Jonathan Wakely redi at gcc dot gnu.org 2012-07-19 
12:19:05 UTC ---
Another option would be to give duration::__rep a NSDMI, which leaves the
testcase valid (as a QoI feature, I believe)


[Bug libstdc++/54025] atomicchrono::duration won't compile: chrono::duration::duration() is not C++11 compliant

2012-07-19 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54025

--- Comment #10 from Paolo Carlini paolo.carlini at oracle dot com 2012-07-19 
12:23:40 UTC ---
I see. For now I would rather just minimally tweak to testcase. If you want to
play a bit more with this and experiment with the various options, just let me
know.


[Bug libstdc++/54025] atomicchrono::duration won't compile: chrono::duration::duration() is not C++11 compliant

2012-07-19 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54025

--- Comment #11 from Jonathan Wakely redi at gcc dot gnu.org 2012-07-19 
12:34:19 UTC ---
Oh, I think our current code might be intentional, we should ask Benjamin:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3303.html

See c++std-lib-32464 for rational for the std semantics i.e.
durationtrivial_type is a trivial type, and leaves the rep uninitialized.


[Bug libstdc++/54025] atomicchrono::duration won't compile: chrono::duration::duration() is not C++11 compliant

2012-07-19 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54025

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

 CC||bkoz at gcc dot gnu.org,
   ||daniel.kruegler at
   ||googlemail dot com

--- Comment #12 from Paolo Carlini paolo.carlini at oracle dot com 2012-07-19 
12:48:19 UTC ---
Ah! Let's add in CC both Benjamin and Daniel then.


[Bug libstdc++/54025] atomicchrono::duration won't compile: chrono::duration::duration() is not C++11 compliant

2012-07-19 Thread daniel.kruegler at googlemail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54025

--- Comment #13 from Daniel Krügler daniel.kruegler at googlemail dot com 
2012-07-19 15:18:16 UTC ---
(In reply to comment #12)
 Ah! Let's add in CC both Benjamin and Daniel then.

I more and more tend to change my mind: I recommend to ignore the
recommendation of N3303 and to make duration conforming with the current
library spec. The described use-case here makes very much sense to me and
demonstrates to me that N3303 did overreact here. But I would be happy to hear
Benjamin's position as well.


[Bug libstdc++/54025] atomicchrono::duration won't compile: chrono::duration::duration() is not C++11 compliant

2012-07-19 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54025

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 AssignedTo|unassigned at gcc dot   |paolo.carlini at oracle dot
   |gnu.org |com
   Target Milestone|--- |4.8.0

--- Comment #14 from Paolo Carlini paolo.carlini at oracle dot com 2012-07-19 
15:25:39 UTC ---
Thanks Daniel. Therefore let's wait a bit in case Benjamin disagrees, otherwise
I'll take care of applying patchlet + testcase + tweak to the existing
constexpr testcase,


[Bug libstdc++/54025] atomicchrono::duration won't compile: chrono::duration::duration() is not C++11 compliant

2012-07-18 Thread chip at pobox dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54025

--- Comment #1 from Chip Salzenberg chip at pobox dot com 2012-07-19 02:56:57 
UTC ---
Created attachment 27829
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=27829
patch to duration default ctor