--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CALekkJdbyqTVT8w%3DU7jWFy-1mXxfw2aEYjYKEGQs%2BkRTmQk7Tg%40mail.gmail.com.
This is awesome, Wez! One question, as I'm not very familiar with [[noreturn]]: does this also cause the function to immediately exit? (In debug, in release?) In particular, another pattern I've seen is:if (SomeAssumptionViolated()) {// This *should* never happen, but can in the cases of [x, y, z]. Handle it gracefully.NOTREACHED();return;}We generally discourage this, but there are a few cases where it's common enough practice (say, handling for corruption, etc). With [[noreturn]], is the return; still necessary, particularly in release builds (where we won't crash)?
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/30d0dd9d-26a8-4244-9c01-16f2b2d53c10%40chromium.org.
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.
Returning from a noreturn function is undefined behavior. The compiler is free to remove all code after noreturn functions, or do whatever else it wants. So this pattern is unsafe.
Returning from a noreturn function is undefined behavior. The compiler is free to remove all code after noreturn functions, or do whatever else it wants. So this pattern is unsafe.Is NOTREACHED() still [[noreturn]] (and thus this pattern unsafe) if DCHECK is off? If not, then this should be fine (because any cases where DCHECK is on, this just crashes, and the compiler can do what it wants).I haven't done a sophisticated grep yet, but just skimming through codesearch for NOTREACHED(), there seem to be many instances of `if (<some_condition>) { NOTREACHED(); return [x]; }`.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAMGbLiG3u2enxtVetT3BZPCyDtyM7RPngg%3D4%3DVeBkhYSeBCh9g%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAKFU2SAOgscWb8xC_vsxCBgMO5uCzaM9p2hcpB6rh7nS7kFcRg%40mail.gmail.com.
D'oh! Yeah, NOTREACHED() doesn't get the treatment in Release, sadly.We could switch it to IMMEDIATE_CRASH() in Release but as Nico suggests, I suspect that may be a little involved to make stable...
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CALekkJfQy-ha-GVu_FY4hFT0Lx-5E_M3dQ3RzTY4sPqq86P%3D8g%40mail.gmail.com.
On Thu, Jun 7, 2018 at 11:27 AM Wez <w...@chromium.org> wrote:D'oh! Yeah, NOTREACHED() doesn't get the treatment in Release, sadly.We could switch it to IMMEDIATE_CRASH() in Release but as Nico suggests, I suspect that may be a little involved to make stable...Why do we want to treat NOTREACHED() differently than DCHECK()? We don't recomment writing CHECKs unless its a security issue, tracking down a bug, etc. DCHECKs document that something won't happen, just the same as NOTREACHED() does.
On Thu, Jun 7, 2018 at 11:33 AM, <dan...@chromium.org> wrote:On Thu, Jun 7, 2018 at 11:27 AM Wez <w...@chromium.org> wrote:D'oh! Yeah, NOTREACHED() doesn't get the treatment in Release, sadly.We could switch it to IMMEDIATE_CRASH() in Release but as Nico suggests, I suspect that may be a little involved to make stable...Why do we want to treat NOTREACHED() differently than DCHECK()? We don't recomment writing CHECKs unless its a security issue, tracking down a bug, etc. DCHECKs document that something won't happen, just the same as NOTREACHED() does.Because then you can mark it noreturn, which is kind of nice.
On Thu, Jun 7, 2018 at 11:34 AM Nico Weber <tha...@chromium.org> wrote:On Thu, Jun 7, 2018 at 11:33 AM, <dan...@chromium.org> wrote:On Thu, Jun 7, 2018 at 11:27 AM Wez <w...@chromium.org> wrote:D'oh! Yeah, NOTREACHED() doesn't get the treatment in Release, sadly.We could switch it to IMMEDIATE_CRASH() in Release but as Nico suggests, I suspect that may be a little involved to make stable...Why do we want to treat NOTREACHED() differently than DCHECK()? We don't recomment writing CHECKs unless its a security issue, tracking down a bug, etc. DCHECKs document that something won't happen, just the same as NOTREACHED() does.Because then you can mark it noreturn, which is kind of nice.I see. Would you expect the binary size delta to be insignificant?
On Thu, Jun 7, 2018 at 11:35 AM, <dan...@chromium.org> wrote:On Thu, Jun 7, 2018 at 11:34 AM Nico Weber <tha...@chromium.org> wrote:On Thu, Jun 7, 2018 at 11:33 AM, <dan...@chromium.org> wrote:On Thu, Jun 7, 2018 at 11:27 AM Wez <w...@chromium.org> wrote:D'oh! Yeah, NOTREACHED() doesn't get the treatment in Release, sadly.We could switch it to IMMEDIATE_CRASH() in Release but as Nico suggests, I suspect that may be a little involved to make stable...Why do we want to treat NOTREACHED() differently than DCHECK()? We don't recomment writing CHECKs unless its a security issue, tracking down a bug, etc. DCHECKs document that something won't happen, just the same as NOTREACHED() does.Because then you can mark it noreturn, which is kind of nice.I see. Would you expect the binary size delta to be insignificant?I'd say this is more about developer ergonomics than binary size, yes.Oh, you probably "do you expect binary size will go up a lot if we ship CHECKs everywhere we have NOTREACHEDs", not "do you expect binary size to go down since the compiler can optimize more" :-)Currently, `NOTREACHED(); return val;` moves val into eax and jumps to the function exit point. CHECK() is something like `int3; ud2; push __COUNTER` which can be done in 5 bytes, so that might be a bit less than the mov and the jmp, or at least not a ton more. We have ~6000 NOTREACHED()s, so I think it's going to be a wash.
I haven't done a sophisticated grep yet, but just skimming through codesearch for NOTREACHED(), there seem to be many instances of `if (<some_condition>) { NOTREACHED(); return [x]; }`
On Thu, 7 Jun 2018 at 08:42, Nico Weber <tha...@chromium.org> wrote:On Thu, Jun 7, 2018 at 11:35 AM, <dan...@chromium.org> wrote:On Thu, Jun 7, 2018 at 11:34 AM Nico Weber <tha...@chromium.org> wrote:On Thu, Jun 7, 2018 at 11:33 AM, <dan...@chromium.org> wrote:On Thu, Jun 7, 2018 at 11:27 AM Wez <w...@chromium.org> wrote:D'oh! Yeah, NOTREACHED() doesn't get the treatment in Release, sadly.We could switch it to IMMEDIATE_CRASH() in Release but as Nico suggests, I suspect that may be a little involved to make stable...Why do we want to treat NOTREACHED() differently than DCHECK()? We don't recomment writing CHECKs unless its a security issue, tracking down a bug, etc. DCHECKs document that something won't happen, just the same as NOTREACHED() does.Because then you can mark it noreturn, which is kind of nice.I see. Would you expect the binary size delta to be insignificant?I'd say this is more about developer ergonomics than binary size, yes.Oh, you probably "do you expect binary size will go up a lot if we ship CHECKs everywhere we have NOTREACHEDs", not "do you expect binary size to go down since the compiler can optimize more" :-)Currently, `NOTREACHED(); return val;` moves val into eax and jumps to the function exit point. CHECK() is something like `int3; ud2; push __COUNTER` which can be done in 5 bytes, so that might be a bit less than the mov and the jmp, or at least not a ton more. We have ~6000 NOTREACHED()s, so I think it's going to be a wash.I'd expect that the binary size will be more-or-less the same, or possibly slightly smaller.However, rather than speculate, I'll do a Release build with NOTREACHED set to IMMEDIATE_CRASH and report back here. :)
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CALekkJduMt-J5%3DfyFZxP2%2Bo73_vEDaEe%3Dw%3Dgm7mJkRx2dOCXrw%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAKSzg3QG1gT%3DPkjJ5F8k0eNfX2WY0yUP6njgUAJ-3fpNQ%3D%2Bm3g%40mail.gmail.com.
So basically UNREACHABLE() adds intentionally unreachable code. This will make -Wunreachable-code pretty useless (though gcc seems to have dropped that option a while back). I much prefer compile time diagnostics to crash reports.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAKSzg3QG1gT%3DPkjJ5F8k0eNfX2WY0yUP6njgUAJ-3fpNQ%3D%2Bm3g%40mail.gmail.com.
On Fri, Jun 8, 2018 at 5:17 AM, Daniel Bratell <bra...@opera.com> wrote:So basically UNREACHABLE() adds intentionally unreachable code. This will make -Wunreachable-code pretty useless (though gcc seems to have dropped that option a while back). I much prefer compile time diagnostics to crash reports.Huh? On the contrary, -Wunreachable-code can infer that things after UNREACHABLE are unreachable in v8, which makes it more useful there.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAKSzg3QG1gT%3DPkjJ5F8k0eNfX2WY0yUP6njgUAJ-3fpNQ%3D%2Bm3g%40mail.gmail.com.
--/* Opera Software, Linköping, Sweden: CEST (UTC+2) */
if (foo) {...} else if (bar) {...} else {UNREACHABLE();}
switch (foo) {case A: return 1;case B: return 2;}UNREACHABLE();// return 0; // not needed thanks to [[noreturn]]