[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] Fwd: Bug#322913: tcc: _Bool exists but doesn't comply
From: |
Marcelo Jimenez |
Subject: |
Re: [Tinycc-devel] Fwd: Bug#322913: tcc: _Bool exists but doesn't comply with C99 |
Date: |
Tue, 30 Aug 2005 02:32:39 -0300 |
Please try the following patch:
Index: tcc.c
===================================================================
RCS file: /cvsroot/tinycc/tinycc/tcc.c,v
retrieving revision 1.172
diff -u -r1.172 tcc.c
--- tcc.c 17 Jun 2005 22:05:58 -0000 1.172
+++ tcc.c 30 Aug 2005 05:23:36 -0000
@@ -5822,6 +5822,7 @@
/* we handle char/short/etc... with generic code */
if (dbt != (VT_INT | VT_UNSIGNED) &&
dbt != (VT_LLONG | VT_UNSIGNED) &&
+ dbt != VT_BOOL &&
dbt != VT_LLONG)
dbt = VT_INT;
if (c) {
@@ -5836,6 +5837,10 @@
case VT_DOUBLE: vtop->c.ui = (unsigned
int)vtop->c.d; break;
case VT_LDOUBLE: vtop->c.ui = (unsigned
int)vtop->c.d; break;
}
+ break;
+ case VT_BOOL:
+ vpushi(0);
+ gen_op(TOK_NE);
break;
default:
/* int case */
===================================================================
Hi,
A Debian user reported this bug about C99 compliance in TCC.
-------------------- Start of forwarded message --------------------
From: Hrvoje Niksic <address@hidden>
Subject: Bug#322913: tcc: _Bool exists but doesn't comply with C99
To: Debian Bug Tracking System <address@hidden>
Date: Sat, 13 Aug 2005 16:02:18 +0200
Package: tcc
Version: 0.9.23-1
Severity: normal
Tcc doesn't correctly implement casts from floating point types to _Bool.
According to C99, such casts must return true for all numbers except 0:
When any scalar value is converted to _Bool, the result is 0 if the value
compares equal to 0; otherwise, the result is 1.
This means that (_Bool) 0.1 must be 1; with tcc it's 0. The following
trivial program can be used to test this:
#include <stdio.h>
int
main (void)
{
printf ("%d\n", (_Bool) 0.1);
return 0;
}
The program prints 1 under Gcc (and other C99-compliant compilers I tested
it with, such as Sun's cc) and 0 under Tcc. I know that Tcc doesn't aim for
C99 conformance, but it's confusing that it implements the _Bool type which
comes from C99, but not the associated semantics.
-------------------- End of forwarded message --------------------
Thanks,
--
,''`.
: :' : Romain Francoise <address@hidden>
`. `' http://people.debian.org/~rfrancoise/
`-
float-to-bool-cast.patch
Description: Text Data