[cfe-commits] r140459 - in /cfe/trunk: lib/AST/ExprConstant.cpp lib/CodeGen/CGExprScalar.cpp lib/Sema/SemaInit.cpp test/CodeGenCXX/cxx0x-initializer-scalars.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Mon Sep 26 10:49:57 PDT 2011


On 26.09.2011, at 17:07, Douglas Gregor wrote:

> 
> On Sep 24, 2011, at 10:48 AM, Sebastian Redl wrote:
> 
>> 
>> +bool IntExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
>> +  if (!Info.Ctx.getLangOptions().CPlusPlus0x)
>> +    return Error(E);
>> +
>> +  if (E->getNumInits() == 0)
>> +    return Success(0, E);
>> +
>> +  assert(E->getNumInits() == 1 && "Excess initializers for integer in C++11.");
>> +  return Visit(E->getInit(0));
>> +}
> 
> I'm flip-flopping a little on whether I would prefer:
> 
> 	if (!Info.Ctx.getLangOptions().CPlusPlus0x || E->getNumInits() > 1)
> 
> so we don't have the assertion. It seems overly picky to assert on this kind of thing, when it is allowed in some dialects. Perhaps I'm just being paranoid.

Init list checking doesn't allow excess initializers for scalars in any C++ dialect. I would rather like to catch any change in this behavior, instead of silently
ignoring all but the first initializer.

Sebastian



More information about the cfe-commits mailing list