RESOLVED FIXED 33056
Implement NO_RETURN for MSVC
https://bugs.webkit.org/show_bug.cgi?id=33056
Summary Implement NO_RETURN for MSVC
Patrick R. Gansterer
Reported 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).
Attachments
Implement NO_RETURN for MSVC (953 bytes, patch)
2009-12-30 09:41 PST, Patrick R. Gansterer
aroben: review-
Fix use of NO_RETURN in FastMalloc.cpp (1.41 KB, patch)
2009-12-30 09:54 PST, Patrick R. Gansterer
mrowe: review-
New patch (2.66 KB, patch)
2010-04-08 09:37 PDT, Patrick R. Gansterer
darin: review-
darin: commit-queue-
The patch (now with NO_RETURN_WITH_VALUE) (2.69 KB, patch)
2010-04-08 12:14 PDT, Patrick R. Gansterer
no flags
Patrick R. Gansterer
Comment 1 2009-12-30 09:41:17 PST
Created attachment 45669 [details] Implement NO_RETURN for MSVC
WebKit Review Bot
Comment 2 2009-12-30 09:47:32 PST
style-queue ran check-webkit-style on attachment 45669 [details] without any errors.
Patrick R. Gansterer
Comment 3 2009-12-30 09:54:59 PST
Created attachment 45670 [details] Fix use of NO_RETURN in FastMalloc.cpp
WebKit Review Bot
Comment 4 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
Mark Rowe (bdash)
Comment 5 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’
Patrick R. Gansterer
Comment 6 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. ;-)
Patrick R. Gansterer
Comment 7 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) :-(
Eric Seidel (no email)
Comment 8 2010-01-03 18:07:17 PST
Some one who knows how MSVC works would have to review the first patch.
Adam Roben (:aroben)
Comment 9 2010-01-04 08:03:46 PST
Comment on attachment 45669 [details] Implement NO_RETURN for MSVC r=me
WebKit Commit Bot
Comment 10 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>
WebKit Commit Bot
Comment 11 2010-01-04 09:06:46 PST
All reviewed patches have been landed. Closing bug.
Darin Adler
Comment 12 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!
Adam Roben (:aroben)
Comment 13 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.
Adam Roben (:aroben)
Comment 14 2010-01-04 09:29:42 PST
Adam Roben (:aroben)
Comment 15 2010-01-04 09:31:47 PST
Re-opening the bug since the patch was rolled out.
Adam Roben (:aroben)
Comment 16 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.
Eric Seidel (no email)
Comment 17 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.
Patrick R. Gansterer
Comment 18 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.
Darin Adler
Comment 19 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.
Patrick R. Gansterer
Comment 20 2010-04-08 09:37:06 PDT
Created attachment 52875 [details] New patch Maybe someone has a better name than NO_VALUE_RETURN ;-)
WebKit Review Bot
Comment 21 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.
Darin Adler
Comment 22 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?
Patrick R. Gansterer
Comment 23 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!
WebKit Review Bot
Comment 24 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.
WebKit Commit Bot
Comment 25 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>
WebKit Commit Bot
Comment 26 2010-04-09 01:36:46 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.