Spurious <=> operator warning in Clang 6.0/C++2a?

Hi all,

Clang 6.0 complains about the string "<=>" even when it's a stringified macro
rather than a token. Is this expected behaviour?

A minimal working example is this:

  #include <cstring>
  #include <cassert>

  #define op <=>
  #define xstr(s) str(s)
  #define str(s) #s

  const char *s = xstr(op);
  const char *s2 = "<=>";

  int main(int argc, char *argv)
  {
    assert(strcmp(s, s2) == 0);
    return 0;
  }

I get the following warning:

foo.cpp:4:12: warning: '<=>' is a single token in C++2a; add a space to avoid a
change in behavior [-Wc++2a-compat]
      #define op <=>
                 ^

I get this on Arch Linux's release package of Clang (tags/RELEASE_600/final), as
well as development tip-of-tree (LLVM 2c3af0c1 and clang 60cec38f), on Linux.

When preprocessing with `clang++ -E`, the preprocessor emits the same warning
but correctly compiles the two declarations to this:

  const char *s = "<=>";
  const char *s2 = "<=>";

The assertion succeeds (as expected) both when compiling directly, and when
doing the preprocessor step separately (i.e. clang++ -E foo.cpp > foo.i &&
clang++ foo.i && ./a.out). So clang is compiling this code correctly, but I
believe the warning is spurious because the "<=>" is not a token but a string.

Please advise if this is expected, or what might be done about it if not. Please
keep Michael and I copied into this thread. Thank you!

Hi all,

Clang 6.0 complains about the string "<=>" even when it's a stringified macro
rather than a token. Is this expected behaviour?

I don't think so – please file a bug.

Thanks Duncan---filed as bug #36925.

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