Skip to content

Unintended dead code in binary schema generation #295

Description

@mikkelfj

There seems to be unreachable code in src/compiler/codegen_schema.c.

msvc looks at this block between the two breaks and raises a warning. From a glance at the code, its analysis seems valid. I know this isn't strictly related to this PR, but I thought I would bring it to your attention as the code definitely looks strange to me.

Originally posted by @amcn in #262 (comment)

EDIT: the dead code prevent adding a binary schema entry for string array struct fields. This is a FlatCC only feature that should have been mapped to a ubyte array in the schema, but the code was never completed for that (it will be when this issues is fixed).

Activity

  1. amcn commented on Sep 11, 2024

    @amcn

    The different compilers frustratingly each find totally disjoint sets of unreachable blocks, attesting to just how unreliable these warnings are, but I raised this one from msvc to your attention because it definitely seemed both valid and a genuine bug. Looks a bit like a merge that went awry.

    clang found a bunch of other unreachable blocks which seem genuinely unreachable but don't appear malign: the gen_panic macro in src/compiler/codegen_c.h which internally asserts and then exits, so any code after it in a basic block is unreachable.

    Incidentally, gcc accepts the -Wunreachable-code flag but it has no effect on the compiler's behaviour, only being accepted for reasons of backwards compatibility according to their doc.

  2. mikkelfj commented on Sep 12, 2024

    @mikkelfj
    ContributorAuthor

    There is a some standard expression or attribute to indicate a function that does not (always) return.
    I don't recall, but if added, portable library would need to manage it for when compilers don't know about it.

  3. mikkelfj commented on Jul 27, 2026

    @mikkelfj
    ContributorAuthor

    Dead code now changed to map string array into a ubyte array in the binary schema (since Google flatc has no string array concept)
    Fixed in 3a3ba19

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions