An added non-ASCII character case breaks compiled runs

Ouverte Adaptée aux débutants
#690 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
75/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
c, cpp, java, javascript
Domaine
testing-qa, tooling

Piste de recherche

Commencez par charLiteral dans web/compiler-explorer.js et candidateTypeMatches dans web/runners.js pour retracer la manière dont les cas de caractères sont générés et acceptés. Trouvez les tests couvrant ces chemins et ajoutez des cas pour é et un emoji. Le travail est terminé lorsque l’ajout de l’un ou l’autre caractère non ASCII est refusé avec un message le nommant, et que les tests passent.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Observed behavior

An added character case whose cell is a non-ASCII character, such as é or an emoji, is written raw between quotes by charLiteral. C and C++ never hand it over as typed, and Java does only within the Basic Multilingual Plane:

  • C is built with clang on Compiler Explorer, and clang 21 (-std=c17) refuses the literal, so the run reports a compile failure.
  • C++ is built with gcc there, and g++ 15 (-std=c++20) reads 'é' as a multi-character constant, warns, and the solution receives -87 instead of the character. A correct solution can fail the case silently.
  • Java runs on JDK 25 there, and javac 25 receives é correctly (233) but refuses an emoji ("character literal contains more than one UTF-16 code unit"). gino1203 reported an earlier javac that accepts it and passes only the high surrogate, 55357.

Python and JavaScript are not affected.

Expected behavior

A character case either reaches every compiled language as typed or is refused when the case is added, with a message that names the character, as an integer outside 32 bits already is.

Reproduction

At main after #683, with the checkout's web/compiler-explorer.js:

const { nativeLiteral } = await import("./web/compiler-explorer.js");
nativeLiteral("é", "character", "cpp"); // "'é'", raw UTF-8 between quotes

Compiling char c = <that literal>; printf("%d", c); gives -87 with g++ 15 and refuses to compile with clang++ 21; the same in C. Checked locally with gcc 15, clang 21 and Java 25.

Initial analysis
  • Path: charLiteral in web/compiler-explorer.js escapes quotes, backslashes and, after #683, U+0000 to U+001F; every other character is written as is.
  • Reach: candidateTypeMatches in web/runners.js accepts any single code point as a character.
  • Domain: the six character judges (copper-pad-continuity, letter-grid-tracer, letter-panel-tracing, puzzle-grid-save-check, rooftop-panel-footprint, sealed-air-pocket-backfill) take letters, digits, ., 0 or 1, all ASCII. A C or C++ char cannot hold a character outside ASCII as one value, so refusing a non-ASCII character when the case is added is simpler than encoding it.
Action items
  1. Refuse a non-ASCII character case when it is added, naming the character.
  2. Add a test that fails on main for é and an emoji.

Raised by gino1203 in a review of #683.

Langage dominant
Rust
Étoiles
228
Forks
150
Merge moyen
1 j 3 h
PR mergées (30 j)
226

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de sysprog21/codetrial

Toutes les issues de sysprog21/codetrial

Issues similaires

Plus d'issues Rust

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.