2014-03-28 17:14 GMT-04:00 Benoit Jacob <jacob.benoi...@gmail.com>:

>
> 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!
>

Let's see if we can wrap up this conversation soon now. How about:

    MOZ_MAKE_COMPILER_BELIEVE_IS_UNREACHABLE

The idea of _COMPILER_ here is to clarify that this macro is tweaking the
compiler's own view of the surrounding code; and the idea of _BELIEVE_ here
is that the compiler is just going to believe us, even if we say something
absurd, which I believe underlines our responsibility. I'm not a native
English speaker so don't hesitate to point out any awkwardness in this
construct...

And as agreed above, we will also introduce a MOZ_ASSERT_UNREACHABLE macro
doing MOZ_ASSERT(false, msg) and will recommend it for most users.

If anyone has a better proposal or a tweak to this one, speak up! I'd like
to be able to proceed with this soon.

Benoit




>
> Benoit
>
>
>
>>
>> -David
>>
>> --
>> 𝄞   L. David Baron                         http://dbaron.org/   𝄂
>> 𝄢   Mozilla                          https://www.mozilla.org/   𝄂
>>              Before I built a wall I'd ask to know
>>              What I was walling in or walling out,
>>              And to whom I was like to give offense.
>>                - Robert Frost, Mending Wall (1914)
>>
>
>
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to