Bug 33056 - Implement NO_RETURN for MSVC
Summary: Implement NO_RETURN for MSVC
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on: 32939
Blocks:
  Show dependency treegraph
 
Reported: 2009-12-30 09:37 PST by Patrick R. Gansterer
Modified: 2010-04-09 01:36 PDT (History)
7 users (show)

See Also:


Attachments
Implement NO_RETURN for MSVC (953 bytes, patch)
2009-12-30 09:41 PST, Patrick R. Gansterer
aroben: review-
Details | Formatted Diff | Diff
Fix use of NO_RETURN in FastMalloc.cpp (1.41 KB, patch)
2009-12-30 09:54 PST, Patrick R. Gansterer
mrowe: review-
Details | Formatted Diff | Diff
New patch (2.66 KB, patch)
2010-04-08 09:37 PDT, Patrick R. Gansterer
darin: review-
darin: commit-queue-
Details | Formatted Diff | Diff
The patch (now with NO_RETURN_WITH_VALUE) (2.69 KB, patch)
2010-04-08 12:14 PDT, Patrick R. Gansterer
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick R. Gansterer 2009-12-30 09:37:16 PST
Implement the NO_RETURN macro also for MSVC.

From http://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Function-Attributes.html:
It does not make sense for a noreturn function to have a return type other than void. 

I found two files who use the NO_RETURN macro in a wrong way (FastMalloc.cpp and jsc.cpp).
Comment 1 Patrick R. Gansterer 2009-12-30 09:41:17 PST
Created attachment 45669 [details]
Implement NO_RETURN for MSVC
Comment 2 WebKit Review Bot 2009-12-30 09:47:32 PST
style-queue ran check-webkit-style on attachment 45669 [details] without any errors.
Comment 3 Patrick R. Gansterer 2009-12-30 09:54:59 PST
Created attachment 45670 [details]
Fix use of NO_RETURN in FastMalloc.cpp
Comment 4 WebKit Review Bot 2009-12-30 09:59:11 PST
Attachment 45670 [details] did not pass style-queue:

Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
JavaScriptCore/wtf/FastMalloc.cpp:1380:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
Total errors found: 1
Comment 5 Mark Rowe (bdash) 2009-12-30 16:34:24 PST
Comment on attachment 45670 [details]
Fix use of NO_RETURN in FastMalloc.cpp

Given that the function is not intended to return I’m not sure why we’d want to remove the annotation that indicates that.  Anyway, this will break the Mac build (and possibly others):
JavaScriptCore/wtf/FastMalloc.cpp:1431: warning: function might be possible candidate for attribute ‘noreturn’
Comment 6 Patrick R. Gansterer 2009-12-31 00:04:46 PST
(In reply to comment #5)
> (From update of attachment 45670 [details])
> Given that the function is not intended to return I’m not sure why we’d want to
> remove the annotation that indicates that.  Anyway, this will break the Mac
> build (and possibly others):
> JavaScriptCore/wtf/FastMalloc.cpp:1431: warning: function might be possible
> candidate for attribute ‘noreturn’
When you implement NO_RETURN for MSVC then it will throw an warning, because noreturn functions must have a void return type. A solution might be that we disable "warning C4646: function declared with __declspec(noreturn) has non-void return type", but then is the problem with the compiler for WinCE. It seams that it ignores the noreturn and throws always an error!

The other possible solution is, that we don't implement NO_RETURN for MSVC and copy the hack from FastMalloc.cpp to jsc.cpp (see bug 32939). I think that this will win, because GCC is the better/prefered compiler. ;-)
Comment 7 Patrick R. Gansterer 2009-12-31 00:16:53 PST
(In reply to comment #6)
> The other possible solution is, that we don't implement NO_RETURN for MSVC and
> copy the hack from FastMalloc.cpp to jsc.cpp (see bug 32939). I think that this
> will win, because GCC is the better/prefered compiler. ;-)
But then the Win32 compiler will throw "warning C4702: unreachable code".

So mit current solution is #if COMPILER(MSVC) && PLATFORM(WINCE) :-(
Comment 8 Eric Seidel (no email) 2010-01-03 18:07:17 PST
Some one who knows how MSVC works would have to review the first patch.
Comment 9 Adam Roben (:aroben) 2010-01-04 08:03:46 PST
Comment on attachment 45669 [details]
Implement NO_RETURN for MSVC

r=me
Comment 10 WebKit Commit Bot 2010-01-04 09:06:39 PST
Comment on attachment 45669 [details]
Implement NO_RETURN for MSVC

Clearing flags on attachment: 45669

Committed r52741: <http://trac.webkit.org/changeset/52741>
Comment 11 WebKit Commit Bot 2010-01-04 09:06:46 PST
All reviewed patches have been landed.  Closing bug.
Comment 12 Darin Adler 2010-01-04 09:09:56 PST
So it does not break the build to define NO_RETURN but leave FastMalloc.cpp alone? If it does then these should not have been independently reviewed patches!
Comment 13 Adam Roben (:aroben) 2010-01-04 09:24:31 PST
(In reply to comment #12)
> So it does not break the build to define NO_RETURN but leave FastMalloc.cpp
> alone? If it does then these should not have been independently reviewed
> patches!

It does break it. I'm rolling out r52741.
Comment 14 Adam Roben (:aroben) 2010-01-04 09:29:42 PST
Committed r52744: <http://trac.webkit.org/changeset/52744>
Comment 15 Adam Roben (:aroben) 2010-01-04 09:31:47 PST
Re-opening the bug since the patch was rolled out.
Comment 16 Adam Roben (:aroben) 2010-01-04 09:32:37 PST
Comment on attachment 45669 [details]
Implement NO_RETURN for MSVC

r- since this can't land until FastMalloc.cpp is changed.
Comment 17 Eric Seidel (no email) 2010-01-04 13:20:33 PST
Sorry.  The commit-queue only knows how to test on Mac Leopard (WebKit's seemingly primary platform) for now.
Comment 18 Patrick R. Gansterer 2010-01-05 01:51:43 PST
Sorry for the buildbreak! That wasn't my intention. Sorry!

Here is a small sum up:
If you implement the __declspec(noreturn) MSVC will complain on functions with returntyp other than void (e.g. functionQuit). If you remove the NO_RETURN macro from such functions the GCC will throw "warning: function might be possible candidate for attribute ‘noreturn’". If you use exit() not at the end of a function MSVC on Win32 will throw "warning C4702: unreachable code", but on WinCE it complains about a missing return statement if exit() is the last statement.
It's always fun to compile with MSVC, because it has different behaviour on every platform!

Does it make sense to implement the NO_RETURN macro for MSVC?

In the moment only functionQuit in jsc.cpp (bug 32939), is a blocker to compile jsc directly from trunk.
Comment 19 Darin Adler 2010-01-05 08:29:42 PST
You can come up with whatever solution you like, as long as you don’t lower the warning settings or break the build.

We could have multiple NO_RETURN macros to work around the differences in various versions of MSVC. We could have ifdefs at various call sites. I don’t see this as an urgent issue, but it’s fine to try to get it working.
Comment 20 Patrick R. Gansterer 2010-04-08 09:37:06 PDT
Created attachment 52875 [details]
New patch

Maybe someone has a better name than NO_VALUE_RETURN ;-)
Comment 21 WebKit Review Bot 2010-04-08 09:38:37 PDT
Attachment 52875 [details] did not pass style-queue:

Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
JavaScriptCore/wtf/FastMalloc.cpp:1434:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
Total errors found: 1 in 4 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 22 Darin Adler 2010-04-08 12:11:56 PDT
Comment on attachment 52875 [details]
New patch

I think NO_RETURN_WITH_VALUE would be better if only because it doesn't make it seem like the word "no" goes with the word "value". Could you do it with that different name?
Comment 23 Patrick R. Gansterer 2010-04-08 12:14:39 PDT
Created attachment 52885 [details]
The patch (now with NO_RETURN_WITH_VALUE)

(In reply to comment #22)
> (From update of attachment 52875 [details])
> I think NO_RETURN_WITH_VALUE would be better if only because it doesn't make it
> seem like the word "no" goes with the word "value". Could you do it with that
> different name?
Done!
Comment 24 WebKit Review Bot 2010-04-08 12:18:45 PDT
Attachment 52885 [details] did not pass style-queue:

Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
JavaScriptCore/wtf/FastMalloc.cpp:1434:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
Total errors found: 1 in 4 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 25 WebKit Commit Bot 2010-04-09 01:36:39 PDT
Comment on attachment 52885 [details]
The patch (now with NO_RETURN_WITH_VALUE)

Clearing flags on attachment: 52885

Committed r57318: <http://trac.webkit.org/changeset/57318>
Comment 26 WebKit Commit Bot 2010-04-09 01:36:46 PDT
All reviewed patches have been landed.  Closing bug.