Skip to content

Concatenating string literals with different prefixes gives the wrong contents or type #624

Closed

Description

@alpaylan

C11 6.4.5p5: adjacent string literals are concatenated as multibyte sequences, and if any token has an encoding
prefix, the result has that prefix. CompCert gets two cases wrong:

#include <stdio.h>
int main(void) {
  printf("%u\n", (unsigned)(U"a" "é")[1]);     /* expected 233 (U+00E9) */
  printf("%u\n", (unsigned)sizeof(U"a" "é"));  /* expected 12 */
  printf("%d\n", (int)sizeof("" u""));         /* expected 2 */
  printf("%d\n", (int)sizeof("ab" L""));       /* expected 12 */
  return 0;
}
$ ccomp t.c && ./a.out
195
16
1
3
$ ccomp -interp -quiet t.c
195
16
1
3
$ gcc -std=c11 t.c && ./a.out      # gcc 15.2.0
233
12
2
12
$ clang -std=c11 t.c && ./a.out    # clang 21.1.8
233
12
2
12

Tested on master (2685140), x86-64.

Found by differential testing with Ephyra: generated C programs, CompCert
against gcc and clang.

Activity

  1. xavierleroy commented on Nov 22, 2026

    @xavierleroy
    Contributor

    Already reported and fixed in #625.

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