An added non-ASCII character case breaks compiled runs

オープン 初心者向け
#690 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
75/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
c, cpp, java, javascript

調査の方向性

web/compiler-explorer.js の charLiteral と web/runners.js の candidateTypeMatches から始めて、文字のケースがどのように生成され、受け入れられるかを追跡してください。これらの経路をカバーするテストを見つけ、é と絵文字のケースを追加してください。どちらかの非ASCII文字を追加すると、その文字を示すメッセージとともに拒否され、テストが通れば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Rust
スター
228
フォーク
150
平均マージ
1日 3時間
マージ済み PR(30日)
226

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

sysprog21/codetrial のほかの issue

sysprog21/codetrial の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。