[cfe-commits] [libcxx] r145624 - in /libcxx/trunk: include/ lib/ src/
Howard Hinnant
hhinnant at apple.com
Mon Jan 23 08:33:31 PST 2012
On Jan 23, 2012, at 3:38 AM, Jonathan Sauer wrote:
> Hello,
>
> a bit late, but ...
>
>> Modified: libcxx/trunk/include/algorithm
>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=145624&r1=145623&r2=145624&view=diff
>> ==============================================================================
>> --- libcxx/trunk/include/algorithm (original)
>> +++ libcxx/trunk/include/algorithm Thu Dec 1 14:21:04 2011
>> @@ -2678,8 +2712,8 @@
>>
>> result_type operator()();
>>
>> - static const/*expr*/ result_type min() {return _Min;}
>> - static const/*expr*/ result_type max() {return _Max;}
>> + static constexpr result_type min() {return _Min;}
>> + static constexpr result_type max() {return _Max;}
>>
>> friend __rs_default __rs_get();
>> };
>
> When compiling with clang's preliminary support for constexpr, this results in a compile-time error, as the
> class has non-constexpr constructors and a destructor, both of which make the class non-literal, meaning it
> cannot have constexpr methods (FDIS 7.15p8 and 3.9p10).
>
> 7.15p8:
> | A constexpr specifier for a non-static member function [...]. The class of which that function is a member
> | shall be a literal type (3.9)
>
> 3.9p10:
> | A type is a literal type if it is: [...]
> | - a class type (Clause 9) that has all of the following properties:
> | - it has a trivial destructor,
> | - every constructor call and full-expression in the brace-or-equal-initializers for non-static data
> | members (if any) is a constant expression (5.19),
I'll bet this is just the tip of the ice berg as libc++ has never before seen a compiler with constexpr support.
I was just about to change this one item when it occurred to me that this *might* be a clang error. I am far from sure though. 7.1.5p8 is discussing *non-static* member functions. The code is showing a *static* member function. I'm poking around in the standard but haven't yet found a clarification concerning static member functions. But there seems to be some similar code in 26.5.3 [rand.eng].
You could fill a large auditorium with what I still have to learn about constexpr. :-\
Howard
More information about the cfe-commits
mailing list