[llvm-bugs] [Bug 39962] New: MS ABI incompatibility when calling virtual function with single bool parameter

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 11 09:20:39 PST 2018


            Bug ID: 39962
           Summary: MS ABI incompatibility when calling virtual function
                    with single bool parameter
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: cerickson at curedev.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Created attachment 21213
  --> https://bugs.llvm.org/attachment.cgi?id=21213&action=edit
Repro case showing the incorrect behavior

When calling a clang-compiled virtual function from an msvc-compiled function,
the virtual function's single bool parameter is passed incorrectly (an argument
of `false` becomes `true`).

This only happens when optimizations are applied to the msvc-compiled source
file (starting with /O1).

This bug appears in the wild when passing a std::function by value across a
compiler boundary, as in this case here: 


std::function ends up performing a double delete as a result of misinterpreting
a bool argument in this fashion.

I've attached a repro case that can be run on an X64 Windows machine with VS
2017 installed.

The expected output of the test case:

[msc] Calling EnsureFalse(false)
[clang] Inside EnsureFalse(false)

The actual output:

[msc] Calling EnsureFalse(false)
[clang] Inside EnsureFalse(true)

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181211/687d4829/attachment-0001.html>

More information about the llvm-bugs mailing list