Skip to content

UTF-16 character literals get illegally formatted #945

Closed

Description

@tepperly

Here is the original code:

$ cat /tmp/foo.cpp
#include <string>

int main(int argc, char **argv) {
  char16_t c = u'\u007f';
}
$

After running uncrustify uncrustify 0.64_d, I get the following:

$ cat /tmp/newfoo.cpp
#include <string>

int main(int argc, char **argv) {
  char16_t c = u '\u007f';
}
$

The space inserted between the u and the first single quote makes the character literal unpareable.

$ g++ -std=gnu++11 -o /tmp/newfoo.o -c /tmp/newfoo.cpp
/tmp/newfoo.cpp: In function 'int main(int, char**)':
/tmp/newfoo.cpp:4:16: error: 'u' was not declared in this scope
   char16_t c = u '\u007f';
             ^
$

Here is the debug file.

Activity

  1. mihaipopescu commented on Jan 20, 2017

    @mihaipopescu
    Collaborator

    Oh, I think uncrustify doesn't expects the new string or char literals from C++11. Need to add support for that.

  2. j000 commented on Nov 19, 2017

    @j000

    Does that merged PR fix it for C++? I'm having the same issue with C...
    u"test" -> u "test"

  3. CDanU commented on Nov 20, 2017

    @CDanU
    Collaborator

    Yes, the merged commit, and the ones before it handle the prefixes only for C++. I didn't know C11 supports those too. A PR for that will be submitted soon.

  4. j000 commented on Nov 20, 2017

    @j000

    I just wasn't sure if it's working properly for C++, so I asked. It's good to know it does :) Thanks!

  5. added a commit that references this issue on Nov 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions