[cfe-commits] r147026 - in /cfe/trunk: lib/AST/Expr.cpp test/Sema/static-init.c

Eli Friedman eli.friedman at gmail.com
Thu Dec 22 01:33:38 PST 2011


On Thu, Dec 22, 2011 at 12:08 AM, Richard Smith <richard at metafoo.co.uk> wrote:
>> For CXXTemporaryObjectExpr: we give an error for the following. I
>> can't think of any obvious reason why it isn't legal:
>>
>> struct A { int x; }; constexpr A x = A();
>
> That's ill-formed because a constexpr constructor is required to initialize
> all members.

Which constructor?  As far as I can tell, this snippet doesn't call
A's default constructor.

>> For StringLiterals, just trying to run 'char a[2] = "a";' through
>> Evaluate causes issues, but it's hard to come up with a testcase that
>> doesn't involve a patch.
>
> isEvaluatable will try to evaluate as an rvalue, but the initializer is an
> lvalue, and we don't support lvalue-to-rvalue conversions on StringLiterals as
> a whole yet (just on character subobjects). This is partially deliberate: I've
> tried to avoid creating APValues representing the contents of string literals
> (since APValue is horribly inefficient at representing arrays of char), and
> with care we can avoid doing so here.

Okay; that makes sense.

> I've been working towards a different constant value representation which
> eschews this problem (and is generally much more space-efficient); I'd love
> some comments if you have time to look over it:
>
> http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20111128/049672.html

I'll take a look.

-Eli



More information about the cfe-commits mailing list