Skip to content

Incorrect treatment of consecutive ## operators (compared with GCC). #112122

@mrolle45

Description

@mrolle45

-- EDIT -- Added comment with a different example and a different problem, and another comment with a suggested fix.

When a macro definition has either 'a ## ## c', the result differs from GCC. I'm not sure what the standard requires, though I suspect the answer is same as 'a ## c'. It may depend on the order of evaluation of the ## operators.

Sample input

#define FOO(a, b, c) a ## b ## c, a ## ## c
FOO (x, , y)
FOO (x, 42, y)

Output from gcc -E is

xy, xy
x42y, xy

Output from clang -E is

xy, x ##y
x42y, x ##y

clang also emits an error about pasting 'x##'. It's apparently trying to paste the 'x' to the second '##'. Whereas GCC treats the '## ##' as being separated by a blank value and following the placeholder rules.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"diverges-from:edgDoes the clang frontend diverge from edg compiler on this issuediverges-from:gccDoes the clang frontend diverge from gcc on this issuediverges-from:msvcDoes the clang frontend diverge from msvc on this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions