2024-04-20 11:49 AEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000158mercuryBugpublic2010-08-19 17:36
Reportercolanderman 
Assigned Towangp 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0000158: char constants do not unify
DescriptionFor some reason, this code:

if det_from_int(255) = '\xFF\' then print("succeed\n", !IO) else print("fail\n", !IO)

prints "fail". This code however:

if 255 = to_int('\xFF\') then print("succeed\n", !IO) else print("fail\n", !IO)

prints "succeed" as expected.
Additional InformationMercury 10.04, Debian Linux 32-bit
TagsNo tags attached.
Attached Files

-Relationships
+Relationships

-Notes

~0000279

wangp (developer)

Thanks. This bug affects 8-bit character literals in low-level C grades.

The LLDS doesn't differentiate between integer and character constants, and the 0xff character ends up in the C source code as (MR_Integer)255 instead of (MR_Char)255. MR_Char is signed (depends on the compiler) so we end up comparing 255 with -1.
+Notes

-Issue History
Date Modified Username Field Change
2010-08-18 14:31 colanderman New Issue
2010-08-18 14:31 colanderman File Added: charbug.m
2010-08-18 15:32 wangp Note Added: 0000279
2010-08-19 17:36 wangp Status new => resolved
2010-08-19 17:36 wangp Resolution open => fixed
2010-08-19 17:36 wangp Assigned To => wangp
+Issue History