Skip to content

# operator drops the space that a comment stands for #718

Closed

Description

@danmar

In translation phase 3 each comment is replaced by one space character (C §5.1.1.2, C++ [lex.phases]). When an argument is stringified with #, each group of whitespace between tokens becomes one space (C §6.10.3.2), so a comment
between two tokens must give a space in the string.

#define str(x) #x
str(a/**/b)

gcc and clang output "a b". simplecpp outputs "ab".

When comments are kept in the output (like gcc -C), gcc keeps the comment in the string: "a/**/b". simplecpp already does the same, and that should not change.

Activity

  1. added a commit that references this issue on Nov 6, 2026
    2e16061
  2. added a commit that references this issue on Nov 6, 2026
    768e6c3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions