Closed Bug 1451088 Opened 6 years ago Closed 6 years ago

Clang 3.8: error: default initialization of an object of const type 'const js::jit::ArithPolicy' without a user-provided default constructor

Categories

(Core :: JavaScript Engine: JIT, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla61
Tracking Status
firefox-esr52 --- unaffected
firefox59 --- unaffected
firefox60 --- unaffected
firefox61 --- fixed

People

(Reporter: mccr8, Assigned: pbone)

References

Details

(Keywords: regression)

Attachments

(1 file, 2 obsolete files)

I've seen this error before, in bug 1444472, but now it is hitting in some JIT code. I'm using clang 3.8. (I should really figure out how to install a newer compiler version on this Ubuntu machine. The version of GCC it is using is unsupported at all by Firefox...)
jandem asked me about this the other day in IRC:

https://bugzilla.mozilla.org/show_bug.cgi?id=1448821#c10
Maybe the minimum Clang version should get bumped to something that doesn't hit that, if we're going to keep hitting this. Anyways, this finally got me to figure out how to use a newer version of Clang on my machine (I can't use the stock GCC version any more either) through the power of a Google search so it had that positive effect. ;)
Blocks: 1448821
Keywords: regression
Summary: error: default initialization of an object of const type 'const js::jit::ArithPolicy' without a user-provided default constructor → Clang 3.8: error: default initialization of an object of const type 'const js::jit::ArithPolicy' without a user-provided default constructor
Nathan suggested this fix, but it does not work for me.
Nathan suggested I make the ctor public rather than private, which will be useful if anybody else wants to call it... That does fix the compile error for me.
I'm hitting the same thing. I haven't had time to test it yet, but I read in some stackoverflow post that the constructor might need to be _provided_ by the code, not just declared. So if second attempt doesn't work out, maybe try:

constexpr TypePolicy() {};

too.

FWIW the version I'm using with clang is the most up-to-date made available by Apple with XCode on OSX Yosemite (I'm also trying to figure out how to update it but I don't know how that will interact with everything else).

Otherwise, I wonder if there's a way to make clang ignore this error..
Attachment #8964679 - Attachment is obsolete: true
The patch I posted works for me, at least on Linux with Clang 3.8.
Argh, that doesn't work for me :'(. To make it work here, the constructor needs to be declared on every subclass of TypePolicy..
(In reply to Andrew McCreight [:mccr8] from comment #2)
> Maybe the minimum Clang version should get bumped to something that doesn't
> hit that, if we're going to keep hitting this.

Yeah, what would it take to require Clang 3.9 (or something newer)? Automation does not use 3.8, we bumped GCC and MSVC recently, and apparently not that many of us are using Clang 3.8 locally.
This patch adds a default constructor to each of the TypePolicy subclasses.  It fixes the problem for me on clang-3.8, Linux Mint (Ubuntu 16.04).
Assignee: nobody → pbone
Attachment #8964686 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #8968529 - Flags: review?(continuation)
Comment on attachment 8968529 [details] [diff] [review]
Bug 1454637 - Add constexpr constructors to the TypePolicy classes

Review of attachment 8968529 [details] [diff] [review]:
-----------------------------------------------------------------

This looks fine to me, but it should get review from a JS peer.
Attachment #8968529 - Flags: review?(continuation) → review?(jdemooij)
Comment on attachment 8968529 [details] [diff] [review]
Bug 1454637 - Add constexpr constructors to the TypePolicy classes

Review of attachment 8968529 [details] [diff] [review]:
-----------------------------------------------------------------

::: js/src/jit/TypePolicy.h
@@ +81,4 @@
>  class BoxInputsPolicy final : public TypePolicy
>  {
>    public:
> +    constexpr BoxInputsPolicy() { };

Remove the trailing ';' off all these.
Attachment #8968529 - Flags: review?(jdemooij) → review+
Pushed by pbone@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/bcbb16742a22
Add constexpr constructors to the TypePolicy classes r=waldo
https://hg.mozilla.org/mozilla-central/rev/bcbb16742a22
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla61
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.