View Issue Details

IDProjectCategoryView StatusLast Update
0031076RunnerFunctionsPublic2019-08-19 12:23
ReporterStewart BishopAssigned ToRussell Kay 
PriorityLowSeverityC - GeneralReproducibility100%
Status ClosedResolutionFixed 
Product Version2.2.3 
Target Version2.2.4Fixed in Version2.2.4 
Summary0031076: Functions: draw_sprite_ext doesn't work on YYC if color is set to -1
DescriptionIf you do the following code:

var color = -1;
draw_sprite_ext(sprite0, 0, 640, 360, 1, 1, 0, color, 1);

For a sprite which is a yellow circle, on VM this will render the circle with the color yellow as expected however on YYC this circle will be black but if you do the following code:

var color = -1;
draw_sprite_ext(sprite0, 0, 640, 360, 1, 1, 0, color, 1);

Then your circle will be yellow on both VM and YYC so it seems like calling c_white in between the variable definition and draw_sprite_ext fixes this for some reason.

Also if you call a debug message to c_white anywhere else in the code this won't fix the issue either so the debug message has to be in a very specific location.
Steps To Reproduce1) Run the sample on YYC
2) See that the circle is black
3) Comment out the debug message in the draw event
4) Run the sample on YYC again
5) See that this now works
TagsRunner, yyc
1.4 Found In
2.x Runtime Found In2.2.3.338
2.x Runtime Verified In9.9.1.1531


Stewart Bishop

2019-06-24 10:55


black_sprite.yyz (31,702 bytes)

Russell Kay

2019-07-01 14:26

Manager   ~0064314

Last edited: 2019-07-01 15:45

View 4 revisions

the reason is that clang is turning (unsigned int)-1.0 into a value of 0 rather than 0xffffffff like Visual Studio does... I will have to delve further into why this is happening

So looks like this is undefined behaviour, Visual Studio will convert -1.0 into 0xffffffff but clang does not (and will not)...

This is not a bug as such as it is using undefined behaviour for converting from a number to a colour
not sure why clang decides on changing this when the show_debug_message call is inserted

Ok just checked and without the show_debug_message call then the compiler optimises the conversion and does it internally creating a constant of 0 (rather than the 0xffffffff) and with the show_debug_message call the optimiser does not collapse it into a 0 but creates code that (correctly?) will convert the -1 to 0xffffffff.

Congratulations I think we have found a clang bug??? not sure it is a bug as it is exploiting undefined behaviour.... -1 is not a colour.

Russell Kay

2019-07-01 16:38

Manager   ~0064316

Fixed in gitlab