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. -Jeff ----- Original Message ----- From: "Steve Fink" <sf...@mozilla.com> To: "Benoit Jacob" <jacob.benoi...@gmail.com> Cc: "Chris Peterson" <cpeter...@mozilla.com>, "dev-platform" <dev-platform@lists.mozilla.org> Sent: Friday, March 28, 2014 1:20:39 PM Subject: Re: MOZ_ASSUME_UNREACHABLE is being misused On Fri 28 Mar 2014 01:05:34 PM PDT, Benoit Jacob wrote: > 2014-03-28 13:23 GMT-04:00 Chris Peterson <cpeter...@mozilla.com>: > >> On 3/28/14, 12:25 PM, Benoit Jacob wrote: >> >>> Should we give typical code a macro that does what they want and sounds >>> like what they want? Really, what typical code wants is a no-operation >>> instead of undefined-behavior; now, that is exactly the same as >>> MOZ_ASSERT(false, "error"). Maybe this syntax is unnecessarily annoying, >>> and it would be worth adding a macro for that, i.e. similar to MOZ_CRASH >>> but only affecting DEBUG builds? What would be a good name for it? Is it >>> worth keeping a close analogy with the unreachable-marker macro to steer >>> people away from it --- e.g. maybe MOZ_UNREACHABLE_NO_OPERATION or even >>> just MOZ_UNREACHABLE? So that people couldn't miss it when they look for >>> "UNREACHABLE" macros? >>> >> >> How about replacing MOZ_ASSUME_UNREACHABLE with two new macros like: >> >> #define MOZ_ASSERT_UNREACHABLE() \ >> MOZ_ASSERT(false, "MOZ_ASSERT_UNREACHABLE") >> >> #define MOZ_CRASH_UNREACHABLE() \ >> do { \ >> MOZ_ASSUME_UNREACHABLE_MARKER(); \ >> MOZ_CRASH("MOZ_CRASH_UNREACHABLE"); \ >> } while (0) >> > > MOZ_ASSUME_UNREACHABLE_MARKER tells the compiler "feel free to arbitrarily > miscompile this, and anything from that point on in this branch, as you may > assume that this code is unreachable". So it doesn't really serve any > purpose to add a MOZ_CRASH after a MOZ_ASSUME_UNREACHABLE_MARKER. MOZ_OPTIMIZE_FOR_UNREACHABLE? _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform