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