Bug 142524 - GCC: CRASH() should be annotated with NORETURN
Summary: GCC: CRASH() should be annotated with NORETURN
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Minor
Assignee: Nobody
URL:
Keywords:
Depends on: 142629
Blocks:
  Show dependency treegraph
 
Reported: 2015-03-09 19:37 PDT by Michael Catanzaro
Modified: 2015-03-12 10:50 PDT (History)
6 users (show)

See Also:


Attachments
Mark CRASH() as noreturn when compiling with GCC (3.44 KB, patch)
2015-03-09 19:44 PDT, Michael Catanzaro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Catanzaro 2015-03-09 19:37:32 PDT
When I used CRASH() at the end of a function I'm working on, I got this warning:

warning: control reaches end of non-void function [-Wreturn-type]

At first I thought GCC was extremely dumb here, but it turns out that our CRASH() function only gets the noreturn attribute when complied with Clang or MSVC. It should be used with GCC too.

I noticed two side-effects of this change, which are simple enough to fix in the same patch:

* With that attribute added, GCC will warn that WTFCrash and WTFCrashWithSecurityImplication do return, because it's not smart enough to detect calling the null pointer as a noreturn. Easiest fix is to use __builtin_trap like we already do for Clang.

* jsc.cpp intentionally uses a return at the end of a noreturn function to avoid a compiler diagnostic, which now triggers a warning from GCC. The #ifdef here was previously #if !COMPILER(CLANG) && !COMPILER(MSVC) so it must have been added just for GCC, so I've removed it.
Comment 1 Michael Catanzaro 2015-03-09 19:44:25 PDT
Created attachment 248313 [details]
Mark CRASH() as noreturn when compiling with GCC
Comment 2 WebKit Commit Bot 2015-03-10 09:02:21 PDT
Comment on attachment 248313 [details]
Mark CRASH() as noreturn when compiling with GCC

Clearing flags on attachment: 248313

Committed r181326: <http://trac.webkit.org/changeset/181326>
Comment 3 WebKit Commit Bot 2015-03-10 09:02:27 PDT
All reviewed patches have been landed.  Closing bug.
Comment 4 Csaba Osztrogonác 2015-03-12 10:50:50 PDT
(In reply to comment #2)
> Comment on attachment 248313 [details]
> Mark CRASH() as noreturn when compiling with GCC
> 
> Clearing flags on attachment: 248313
> 
> Committed r181326: <http://trac.webkit.org/changeset/181326>

It caused a regression on AArch64 Linux, see bug142629 for details.