Closed Bug 1715538 Opened 3 years ago Closed 3 years ago

Error compiling rooting headers with MSVC

Categories

(Core :: JavaScript: GC, defect)

78 Branch
defect

Tracking

()

RESOLVED DUPLICATE of bug 1716247

People

(Reporter: jonco, Unassigned)

Details

Attachments

(1 file)

We don't support building Mozilla code with MSVC since version 67, but to make life easier for embedders it would be better if it didn't fall over on our headers.

When I’m tryiing to build my testapp.cpp using spiderMonkey in visual studio 2019,it’s 
giving compilation error from GCPolicyAPI.h(line:70) whenever i’m adding jsapi.h in my 
program.

Error: error C2338: Pointer type not allowed for StructGCPolicy

It seems this can be fixed by defining a specialization for GCPolicy<void*>. I don't know if this is the right thing to do, and it would be better to understand what's going wrong before adding a workaround like this.

Original report on discourse: https://discourse.mozilla.org/t/compilation-error-with-jsapi-h-in-vs19-with-esr78/81380

Workaround in cairo: https://gitlab.gnome.org/GNOME/gjs/-/commit/60ae77b1d49e344a8b8e2b2a3c184e7d7f72676f

Here's the possibly minimal testcase.
Compiling this on VisualStudio 2019, with c++17 option hits the static_assert, but not on clang.

So, in certain situation, MSVC instantiates unnecessary templates.

The "pointer type" assertion is supposed not to hit for T = RootListEntry*, because T = RootListEntry* case is used only for pointer type and it's not supposed to be instantiated,
but given above, MSVC instantiates the case, and hits the "pointer type" assertion.

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: