Skip to content

more warnings - #363

Merged
Smattr merged 12 commits into
mainfrom
smattr/f8dad399-46d6-4a88-abb2-b32a9b559747
Oct 17, 2026
Merged

Smattr merged 12 commits into
mainfrom
smattr/f8dad399-46d6-4a88-abb2-b32a9b559747

Conversation

@Smattr

@Smattr Smattr commented Oct 15, 2026

Copy link
Copy Markdown
Owner

No description provided.

@Smattr
Smattr force-pushed the smattr/f8dad399-46d6-4a88-abb2-b32a9b559747 branch from bb96632 to f80dd7a Compare October 15, 2026 00:56
GCC says:

  murphi-format/src/lex_get_token.c: In function ‘lex_get_token’:
  murphi-format/src/lex_get_token.c:259:28: warning: conversion from
    ‘int’ to ‘char’ may change value [-Wconversion]
    259 |     if (may_be_operator(0, first)) {
        |                            ^~~~~
  murphi-format/src/lex_get_token.c:320:33: warning: conversion from
    ‘int’ to ‘char’ may change value [-Wconversion]
    320 |         if (!may_be_operator(i, c)) {
        |                                 ^

An interesting quirk is that my initial attempt to fix this by making
`may_be_operator` accept an `int` failed on platforms with signed
`char`. When reading signed `char` values out of `OPERATORS` they are
then sign-extended when comparing against (the now `int`) `c`. For
values < 0, this sign extension produces a different value than the cast
to `unsigned char` that `getc` does.

This change observes that the arguments passed in originated from
`getc`, so we should respect that they were delivered to us as
`unsigned char` values.

Reported-by: GCC 16.2.1
GCC says:

  murphi2murphi/src/Pipeline.cc: In member function
    ‘void Pipeline::finalise()’:
  murphi2murphi/src/Pipeline.cc:33:40: warning: signed conversion from
    ‘unsigned int’ to ‘rumur::position::counter_type’ {aka ‘int’}
    changes value from ‘4294967295’ to ‘-1’ [-Wsign-conversion]
    33 |   stages[0]->sync_to(position(nullptr, UINT_MAX, UINT_MAX));
       |                                        ^~~~~~~~
  murphi2murphi/src/Pipeline.cc:33:50: warning: signed conversion from
    ‘unsigned int’ to ‘rumur::position::counter_type’ {aka ‘int’}
    changes value from ‘4294967295’ to ‘-1’ [-Wsign-conversion]
    33 |   stages[0]->sync_to(position(nullptr, UINT_MAX, UINT_MAX));
       |                                                  ^~~~~~~~

Reported-by: GCC 16.2.1
GCC says:

  In file included from murphi2xml/src/XMLPrinter.cc:1:
  murphi2xml/src/XMLPrinter.h:101:70: warning: signed conversion from
    ‘unsigned int’ to ‘rumur::position::counter_type’ {aka ‘int’}
    changes value from ‘4294967295’ to ‘-1’ [-Wsign-conversion]
    101 |   void sync_to(…, UINT_MAX,
        |                   ^~~~~~~~
  murphi2xml/src/XMLPrinter.h:102:61: warning: signed conversion from
    ‘unsigned int’ to ‘rumur::position::counter_type’ {aka ‘int’}
    changes value from ‘4294967295’ to ‘-1’ [-Wsign-conversion]
    102 |    UINT_MAX));
        |    ^~~~~~~~
  In file included from murphi2xml/src/main.cc:2:
  murphi2xml/src/XMLPrinter.h:101:70: warning: signed conversion from
    ‘unsigned int’ to ‘rumur::position::counter_type’ {aka ‘int’}
    changes value from ‘4294967295’ to ‘-1’ [-Wsign-conversion]
    101 |   void sync_to(…, UINT_MAX,
        |                   ^~~~~~~~
  murphi2xml/src/XMLPrinter.h:102:61: warning: signed conversion from
    ‘unsigned int’ to ‘rumur::position::counter_type’ {aka ‘int’}
    changes value from ‘4294967295’ to ‘-1’ [-Wsign-conversion]
    102 |    UINT_MAX));
        |    ^~~~~~~~

Reported-by: GCC 16.2.1
GCC says:

  rumur/src/process.cc: In function ‘int run(…
  rumur/src/process.cc:250:36: warning: conversion to ‘long unsigned
    int’ from ‘off_t’ {aka ‘long int’} may change the sign of the result
    [-Wsign-conversion]
    250 |                     input.size() - input_offset);
        |                                    ^~~~~~~~~~~~

Reported-by: GCC 16.2.1
@Smattr
Smattr force-pushed the smattr/f8dad399-46d6-4a88-abb2-b32a9b559747 branch 2 times, most recently from 49530ac to 2c23dd7 Compare October 17, 2026 01:38
Apart from de-duplicating code, this unifies on the idiom
`assert(0 && "unreachable")` as opposed to `assert(!"unreachable")`, the
latter of which triggers Clang -Wstring-conversion warnings.

Reported-by: AppleClang 21.0.0.21000101
…sion

Reported-by: AppleClang 21.0.0.21000101
Reported-by: AppleClang 21.0.0.21000101
This required suppressing this on Flex-generated code. Without this,
compilation with Clang (AppleClang 21.0.0.21000334) on macOS triggers
warnings in Flex boilerplate.

As with 4c9fd5b, we need to disable
this warning on x86-64 macOS in CI because otherwise it triggers on
libgmp headers. As with 4c9fd5b, I do
not understand why `SYSTEM` does not suppress these nor why only a
subset of macOS builds are affected.
GCC says:

  rumur/src/smt/translate.cc: In function ‘std::string smt::lower(const
    std::string&)’:
  rumur/src/smt/translate.cc:281:11: warning: conversion from ‘int’ to
    ‘char’ may change value [-Wconversion]
    281 |     s1 += (int)tolower(c);
        |           ^~~~~~~~~~~~~~~

Reported-by: GCC 16.2.1
This required suppressing Wshorten-64-to-32 on Flex-generated code.
Without this, compilation with Clang (AppleClang 21.0.0.21000334) on
macOS triggers warnings in Flex boilerplate.

As with 4c9fd5b, we need to partially
disable this warning on x86-64 macOS in CI because otherwise it triggers
on libgmp headers. As with 4c9fd5b, I
do not understand why `SYSTEM` does not suppress these nor why only a
subset of macOS builds are affected.
@Smattr
Smattr force-pushed the smattr/f8dad399-46d6-4a88-abb2-b32a9b559747 branch from 2c23dd7 to 99f63da Compare October 17, 2026 15:31
@Smattr
Smattr merged commit ab5286a into main Oct 17, 2026
25 checks passed
@Smattr
Smattr deleted the smattr/f8dad399-46d6-4a88-abb2-b32a9b559747 branch October 17, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant