Emitted C draws warnings, or fails, in a few shapes #69

Open
opened 2026-10-19 14:09:43 +02:00 by alex-eg · 0 comments
Owner

The C sexc writes is valid in all these shapes but one; but it draws warnings from -Wall, or reads less clearly than it could:

  • case/fallthrough emits no annotation, so clang's -Wimplicit-fallthrough fires on exactly the fallthrough that was asked for:

    (switch a (case/fallthrough 1 (g a)) (case 2 (g a)))
    warning: unannotated fall-through between switch labels
    

    C23 has [[fallthrough]];; gcc and clang take __attribute__((fallthrough)); before that.

  • Operators of different precedence are written without the parentheses -Wparentheses asks for, though C reads them right:

    (& 6 (== a b))         ->   6 & a == b
    (<< (+ a 1) (- b 1))   ->   a + 1 << b - 1
    
  • A local [* const char] with no initializer declares const char * x[];, which C refuses: an array of unknown size needs an initializer, except as a parameter or an extern.

  • (fn () void) is written void (*cb)(). Before C23, () declares a function of unspecified parameters, not of none; (void) says none.

Cosmetic, for reading -C output:

  • a static function's body is indented 11 columns;
  • the blank lines before #line directives carry trailing spaces;
  • a const before an aggregate written in place, (* const (struct ((c int)))), indents the aggregate's body to where const pushed its first line.

Found with sexc 35604ad, probing corner cases the test suite does not cover; the rest of what that turned up is fixed on more-tests-and-corner-cases.

The C sexc writes is valid in all these shapes but one; but it draws warnings from `-Wall`, or reads less clearly than it could: - `case/fallthrough` emits no annotation, so clang's `-Wimplicit-fallthrough` fires on exactly the fallthrough that was asked for: (switch a (case/fallthrough 1 (g a)) (case 2 (g a))) warning: unannotated fall-through between switch labels C23 has `[[fallthrough]];`; gcc and clang take `__attribute__((fallthrough));` before that. - Operators of different precedence are written without the parentheses `-Wparentheses` asks for, though C reads them right: (& 6 (== a b)) -> 6 & a == b (<< (+ a 1) (- b 1)) -> a + 1 << b - 1 - A local `[* const char]` with no initializer declares `const char * x[];`, which C refuses: an array of unknown size needs an initializer, except as a parameter or an `extern`. - `(fn () void)` is written `void (*cb)()`. Before C23, `()` declares a function of unspecified parameters, not of none; `(void)` says none. Cosmetic, for reading `-C` output: - a `static` function's body is indented 11 columns; - the blank lines before `#line` directives carry trailing spaces; - a `const` before an aggregate written in place, `(* const (struct ((c int))))`, indents the aggregate's body to where `const` pushed its first line. -------- Found with sexc 35604ad, probing corner cases the test suite does not cover; the rest of what that turned up is fixed on `more-tests-and-corner-cases`.
alex-eg added the bug label 2026-10-19 14:09:43 +02:00
Sign in to join this conversation.