[llvm-bugs] [Bug 45005] New: Clang-CL's MSVC preprocessor emulation does not properly handle variadic arguments

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Feb 24 04:48:06 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=45005

            Bug ID: 45005
           Summary: Clang-CL's MSVC preprocessor emulation does not
                    properly handle variadic arguments
           Product: clang
           Version: 9.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: Balazs.CZIRAKI at nng.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Clang-CL's MSVC preprocessor emulation does not produce the exact same behavior
as MSVC's preprocessor, which breaks certain libraries that are prepared to
handle MSVC's preprocessor behavior.

A minimal repro of the error that causes said libraries to break:
https://godbolt.org/z/c5RndM

(Clang-CL is not available on Godbolt, so the output of a local build was
pasted into a comment.)

The example macro `_NARG` counts the arguments it was provided up to three.
Since MSVC's preprocessor has it's quirks, the `_NARG_MSVC` macro is what can
produce the same behavior with that preprocessor.

When given two empty arguments, Clang-CL's preprocessor does not properly
handle the MSVC version, and produces an erroneous argument count of `1`.

This breaks libraries such as:
 * GoogleMock: https://godbolt.org/z/noqbnj
   (The new `MOCK_METHOD` macro in 1.10)
 * Boost Preprocessor: https://godbolt.org/z/NL6BbA

-- 
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/20200224/c1fb46ba/attachment-0001.html>


More information about the llvm-bugs mailing list