Bug 81061 - Functions with C linkage should return POD types
Summary: Functions with C linkage should return POD types
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-13 17:01 PDT by Filip Pizlo
Modified: 2012-03-13 17:46 PDT (History)
2 users (show)

See Also:


Attachments
the patch (3.74 KB, patch)
2012-03-13 17:02 PDT, Filip Pizlo
no flags Details | Formatted Diff | Diff
the patch (3.66 KB, patch)
2012-03-13 17:28 PDT, Filip Pizlo
mrowe: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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