Skip to content

u'...' character constants are converted to unsigned int instead of being promoted to int #623

Closed

Description

@alpaylan

A u'...' constant has type char16_t (unsigned short in CompCert). In an expression it should be promoted to
int (C11 6.3.1.1p2), but CompCert treats it as unsigned int:

#include <stdio.h>
int main(void) {
  printf("%d\n", u'0' < -1);              /* expected 0 */
  printf("%lld\n", (long long)-u'A');     /* expected -65 */
  return 0;
}
$ ccomp t.c && ./a.out
1
4294967231
$ ccomp -interp -quiet t.c
1
4294967231
$ gcc -std=c11 t.c && ./a.out      # gcc 15.2.0
0
-65
$ clang -std=c11 t.c && ./a.out    # clang 21.1.8
0
-65

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. (You guys all use the same LLM ?)

  2. alpaylan commented on Nov 23, 2026

    @alpaylan
    Author

    Already reported and fixed in #625. (You guys all use the same LLM ?)

    Hi @xavierleroy, not sure what the "you guys" refers to, my methodology is public, it's a type of LLM-augmented fuzzing, I was treating CompCert as a hard case study. I assume by already reported you mean privately reported as I haven't seen any existing issues, I apologize if I've missed it.

    I imagine in the early days of fuzzing, multiple people fuzzing the same target hit the same low-hanging bugs too, this seems inevitable with any new primitive. My simple assumption was that the issue tracking in CompCert is public, so any bugs would be novel, I understand that is not the case, I will not file any other bugs to not overwhelm you with any duplicates.

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