This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re: [C++ PATCH] C++0x static assertions

On 11/21/06, Mark Mitchell <> wrote:
Doug Gregor wrote:
> Hi Mark,
> Thanks for reviewing my patch. A revised and improved version is
> attached; some comments are inline.

This version looks very goods. A few nit-picks:

+ error ("%E", message);


error ("static assertion failed: %E", message);

?  I'll leave this to you, but it might help clue people in that this is
not some rule of C++ that was violated, but rather an assertion in the

Sure. I don't have a preference either way.

+      else if (condition && condition != error_mark_node)
+        error ("invalid condition %<%E%> in static assertion",
+               condition);

I don't like using %E for arbitrary expressions.
But, under what circumstances can we get here?  We've converted an
integral constant expression to bool, and we know that we didn't get an
INTEGER_CST.  I can think of one case:

static_assert (7 / 0, "X");

which we will refuse to fold.  (You might want a test-case for that,
just in case; it's the kind of thing that's easy to break.)  I'm not
even sure what the semantics of static_assert are supposed to be in that
case. :-)

I couldn't even think of a case where it would happen, but I wanted to be sure. I've added a test case for this.

I would just say:

error ("non-constant condition for static assertion");


OK with those changes. Or, if you want, let's discuss further.

Committed to mainline with those changes. Final patch is attached.


Attachment: static_assert.patch
Description: Binary data

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]