From: jhbrown@ai.mit.edu (Jeremy H. Brown)
Date: Mon, 24 Jun 96 18:30:06 EDT
Subject: Second attempt: Snoot bug in casting enums
Message-Id: <9606242230.AA11204@tarkin.ai.mit.edu>
I figured out what causes the problem I reported in my last mail. I
don't have a good fix; I kluged a workaround. The problem is that
when an enum value of -1 is handed to constnode, it is promoted to
unsigned int, a representation which is 4294967995. This is larger
than MAX_INT, so it gets stored as a string, so never converted back
again...
Any thoughts on a good fix are welcome; I replaced MAX_INT in
immed::immed(unsigned) with MAX_UINT, but that's probably not
technically safe according to ANSI.
Jeremy
-------
From: jhbrown@ai.mit.edu (Jeremy H. Brown)
Date: Fri, 21 Jun 96 10:45:49 EDT
Sender: owner-suif-bugs@hawg.stanford.edu
Precedence: bulk
Reply-To: suif-bugs@hawg.stanford.edu
My first attempt at reporting this seems to have vanished into the
void; if it shows up later, I'm sorry for the duplication.
Coincidentally, we're compiling SPEC95 here too (just the integer
benchmarks), and have got everything but 126.gcc going. The problem
we've currently got is that snoot does something strange casting enums
-- it seems to change the value to the other type-representation, but
not change the type of the ldc, instead using cvt to convert the type
of the ldc to the cast-type. This program demonstrates the problem:
#include<stdio.h>
enum type_class{no_type_class = -1 };
main() {
int r1, r2;
r1 = ((int ) ( no_type_class )); /* fails */
r2 = ((int) ((char) -5)); /* works fine */
printf("%d\n",abs(r1-r2));
}
----------
symtab info:
t:g42: enum type_class signed 8 {
no_type_class = -1,
}
program info corresponding to the assignments:
2: cvt t:g4 (i.32) main.r1 = e1
3: e1: ldc t:g42 (e.8) 4294967295
20: ldc t:g4 (i.32) main.r2 = -5
----------
output of s2c -pseudo (s2c just crashes):
extern int main()
{
int r1;
int r2;
r1 = 4294967295;
r2 = -5;
printf("%d\n", abs(r1 - r2));
return 0;
}
------------
Is there a simple patch for this?
Thanks in advance,
Jeremy