Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • sac2c sac2c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 334
    • Issues 334
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 14
    • Merge requests 14
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Infrastructure Registry
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Issues
  • #1015

Closed
Open
Created Mar 04, 2012 by Bep Rinto@broGuest

sac2c crashes while parsing nested if-else with multi-return calls

Bugzilla Link 928
Created on Mar 04, 2012 08:15
Version 1.00beta
OS Linux
Architecture PC

Extended Description

/**********************************************************************
 *
 * SAC bug report: testpnm.sacbugreport
 *
 **********************************************************************
 *
 * Automatically generated on Sun Mar  4 09:01:14 CET 2012
 *
 * using sac2c v1.00-beta (Haggis And Apple) rev 17729 for linux-gnu_x86_64
 * built Mon Feb 13 10:00:22 GMT 2012.
 * by user fpz on host dogmatix for linux-gnu.
 *
 * The compiler was called by
 *  sac2c -check tb -v 1 -g -mt -o testpnm_mt testpnm.sac
 *
 * The compiler crashed in
 *  phase: pc (Preparing C code generation)
 *  sub phase: dvr (Removing obsolete variable declarations)
 *
 * What follows is the contents of testpnm.sac.
 *
 **********************************************************************/
/* Test driver for PGM module. */
use StdIO:        { printf, fopen, fclose, ftell, fseek };
use RuntimeError: { error };
use CommandLine:  { argc, argv };
use File:         { File, fgetc, fscanf, feof, ungetc };
use SysErr:       { fail };
import String:    { string, == };
import ScalarArith: all;
import Array:     all;
void skip(File f)
{
}
int, int, int, int read_PNM_header(string name)
{
  int kind, widths, height, maxval;
  File f;
  e, f = fopen(name, "rb");
  if (fail(e)) {
    error( (:int) e, "Could not open %s for reading", name);
  }
  kind = 0;
  widths = 0;
  height = 0;
  maxval = 0;
  if (fgetc(f) == 'P') {
    T = fgetc(f);
    if (T >= '1' && T <= '6') {
      kind = toi(T) - toi('0');
      skip(f);
      n, widths = fscanf(f, " %u");
      if (n == 1) {
        skip(f);
        n, height = fscanf(f, " %u");
      }
      if (kind == 1 || kind == 4) {
        maxval = 1;
      }
      else if (n == 1) {
        skip(f);
        n, maxval = fscanf(f, " %u");
      }
      if (n == 1) {
        skip(f);
      }
    }
  }
  fclose(f);
  return (kind, widths, height, maxval);
}
int main()
{
  if (argc() < 2) {
    error(1, "Need at least one arg");
  }
  for (i = 1; i < argc(); ++i) {
    s = argv(i);
    kind, widths, height, maxval = read_PNM_header(s);
  }
  return 0;
}
/**********************************************************************
 *
 * End of bug report
 *
 **********************************************************************/
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking