View Issue Details

IDProjectCategoryView StatusLast Update
0000108Ecere SDKcompilerpublic2013-09-30 09:05
Reporterjoey Assigned Tojerome  
PriorityurgentSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Target Version0.44.10 64Fixed in Version0.44.10 64 
Summary0000108: Consequential cast ignored; (char*)p + ((unsigned short)-page_free); subtracts instead of adds
DescriptionIn the following code:

void *p = (void*)0x12345678;

unsigned short page_free = 65000;

void *p2 = (char*)p + ((unsigned short)-page_free);
    

printf("Use %p from %p\n", p2, p);

The compiler ignores the cast to unsigned short, resulting in (char*)p + (-page_free), which turns into a subtraction. Compiling and running with eC produces this:
   Use 0x12335890 from 0x12345678
whereas compiling with GCC produces this:
   Use 0x12345890 from 0x12345678

The eC code posted above compiles into this (#line stuff removed):


void * p = (void *)0x12345678;


unsigned short page_free = (unsigned short)65000;


void * p2 = (char *)p + (-page_free);


printf("Use %p from %p\n", p2, p);
Additional InformationTrying to use casts in a printf call is problematic:

byte a = 0x5B;
printf("%x\n", (byte)~a);

The (byte) cast is taken out by the eC compiler.
TagsNo tags attached.

Relationships

related to 0000205 closedjerome Fix integer promotions to follow the C standard (6.3.1.1) 

Activities

jerome

2013-09-23 06:47

administrator   ~0001078

First issue simplified as:

      unsigned short page_free = 65000;
      int a = (unsigned short)-page_free;

jerome

2013-09-30 09:05

administrator   ~0001106

Fixed by:
https://github.com/ecere/ecere-sdk/commit/0deb55d8a3cf19b9b6960c24f076f723ea144667

Issue History

Date Modified Username Field Change
2008-08-10 05:43 joey New Issue
2010-09-20 04:25 jerome Priority normal => urgent
2010-09-20 04:25 jerome Severity minor => major
2010-09-20 04:25 jerome Target Version => 0.44 pre-release 3
2010-09-20 04:25 jerome Additional Information Updated
2012-03-08 15:59 redj Target Version old 0.44.pre3 => 0.45 Ginkakuji
2012-03-29 07:50 redj Category => eC Compiling Tools
2012-03-29 07:50 redj Project @2@ => Ecere SDK
2013-09-23 06:47 jerome Note Added: 0001078
2013-09-23 07:08 jerome Assigned To => jerome
2013-09-23 07:08 jerome Status new => assigned
2013-09-23 07:08 jerome Target Version 0.45 Ginkakuji => 0.44.10 64
2013-09-30 09:05 jerome Status assigned => closed
2013-09-30 09:05 jerome Note Added: 0001106
2013-09-30 09:05 jerome Resolution open => fixed
2013-09-30 09:05 jerome Fixed in Version => 0.44.10 64
2014-05-27 07:01 jerome Relationship added related to 0000205