On 14-03-28 05:14 PM, Benoit Jacob wrote:
2014-03-28 16:48 GMT-04:00 L. David Baron <dba...@dbaron.org>:

On Friday 2014-03-28 13:41 -0700, Jeff Gilbert wrote:
My vote is for MOZ_ASSERT_UNREACHABLE and MOZ_OPTIMIZE_FOR_UNREACHABLE.

It's really handy to have something like MOZ_ASSERT_UNREACHABLE, instead
of having a bunch of MOZ_ASSERT(false, "Unreachable.") lines.
Consider MOZ_ASSERT_UNREACHABLE being the same as
MOZ_OPTIMIZE_FOR_UNREACHABLE in non-DEBUG builds.

I agree on the first (adding a MOZ_ASSERT_UNREACHABLE), but I don't
think MOZ_OPTIMIZE_FOR_UNREACHABLE sounds dangerous enough -- the
name should make it clear that it's dangerous for the code to be
reachable (i.e., the compiler can produce undefined behavior).
MOZ_DANGEROUSLY_ASSUME_UNREACHABLE is one idea I've thought of for
that, though it's a bit of a mouthful.

I too agree on MOZ_ASSERT_UNREACHABLE, and on the need to make the new name
of MOZ_ASSUME_UNREACHABLE sound really scary.

I don't mind if the new name of MOZ_ASSUME_UNREACHABLE is really long, as
it should rarely be used. If SpiderMonkey gurus find that they need it
often, they can always alias it in some local header.

I think that _ASSUME_ is too hard to understand, probably because this
doesn't explicitly say what would happen if the assumption were violated.
One has to understand that this is introducing a *compiler* assumption to
understand that violating it would be Undefined Behavior.

How about....  MOZ_ALLOW_COMPILER_TO_GO_CRAZY  ;-) This is technically
correct, and explicit!
MOZ_UNDEFINED_BEHAVIOUR() ? Undefined behaviour is usually enough to get C/++ programmers' attention.

--m.

_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to