Skip to content

with migrate copies C statements after return, which with check then rejects as unreachable #2781

Closed

Description

@joshhickson
static unsigned long twsize(unsigned long n)
  {
  unsigned long t = 0;
  for (unsigned long k = 0; k < n; ++k) t += k;
  return t;
  return 0;
  }

This is legal C (pocketfft's rfftp_twsize, pocketfft.c:1800-1812, ends exactly like this). The
migrated function keeps both returns, and the output fails with check with "error: unreachable code"
at the second (§20b.5; src/SemaCheck.w:15615). with migrate itself prints the same error about the file
it wrote, and exits 0. So a corpus whose C has a dead statement can't be checked, and there is nothing a
recipe can do about it short of editing the source.

Fix direction (your call). The migrator drops statements that follow an unconditional return,
break, continue or goto in the same block (they can never run, so the translation stays faithful),
perhaps leaving a comment; or migrated modules are exempt from the unreachable-code error.

Checked on Linux x86_64 (WSL2) with release builds of main 14a720bd, 25ac6ac0 and fc27c65e; main is now 455ff0bc, whose three later commits are not about the migrator.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions