Bug 81061

Summary: Functions with C linkage should return POD types
Product: WebKit Reporter: Filip Pizlo <fpizlo>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: mrowe, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
the patch
none
the patch mrowe: review+

Description Filip Pizlo 2012-03-13 17:01:46 PDT
They should return either primitive C types or C structs (i.e. structs that do not have methods).
Comment 1 Filip Pizlo 2012-03-13 17:02:51 PDT
Created attachment 131752 [details]
the patch
Comment 2 WebKit Review Bot 2012-03-13 17:08:25 PDT
Attachment 131752 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/JavaScriptCore/ChangeLog', u'Source..." exit_code: 1
Source/JavaScriptCore/ChangeLog:3:  ChangeLog entry has no bug number  [changelog/bugnumber] [5]
Total errors found: 1 in 3 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Filip Pizlo 2012-03-13 17:28:06 PDT
Created attachment 131758 [details]
the patch

Corrected the comment.

Apparently, the requirements for return types of functions with C linkage match the C++-03 definition of POD (a strict subset of aggregate types - so no C++-style members, only POD fields).  The C++-11 definition has been split up into two separate concepts (trivial and standard-layout).  Prior to this code we were returning standard-layout but not non-trivial (and thus not POD) classes, which is correct in C++-11 but not C++-03.
Comment 4 WebKit Review Bot 2012-03-13 17:30:31 PDT
Attachment 131758 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/JavaScriptCore/ChangeLog', u'Source..." exit_code: 1
Source/JavaScriptCore/ChangeLog:3:  ChangeLog entry has no bug number  [changelog/bugnumber] [5]
Total errors found: 1 in 3 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Mark Rowe (bdash) 2012-03-13 17:32:52 PDT
Comment on attachment 131758 [details]
the patch

View in context: https://bugs.webkit.org/attachment.cgi?id=131758&action=review

Looks fine to me.

> Source/JavaScriptCore/ChangeLog:3
> +        Need a short description and bug URL (OOPS!)

Describe the problem!

> Source/JavaScriptCore/dfg/DFGOperations.h:160
> +// According to C++ rules, a type used for the return signature of function with C linkage (i.e.
> +// 'extern "C"') needs to be POD in the C++-03 sense: loosely speaking it must have nothing more than
> +// those members that would be valid in C. This means no constructors.

I don't think it's necessary to explain what a POD type is here. I'd simplify this to something like:
// Since this type is used in the signature of a function declared with C linkage it must be a POD type.

> Source/JavaScriptCore/llint/LLIntSlowPaths.h:44
> +// According to C++ rules, a type used for the return signature of function with C linkage (i.e.
> +// 'extern "C"') needs to be POD in the C++-03 sense: loosely speaking it must have nothing more than
> +// those members that would be valid in C. This means no constructors.

Same comment about the comment here.
Comment 6 Filip Pizlo 2012-03-13 17:46:23 PDT
Landed in http://trac.webkit.org/changeset/110651