spencersalazar / chuck

28 stars 8 forks source link

win32 Crash when function doesn't return a value #24

Open SSteve opened 10 years ago

SSteve commented 10 years ago

If a function defined as returning a value doesn't return a value, it crashes after a number of invocations. Here's an example from the Coursera class forum:

fun int boom (int inInt)
{
    <<< "x" >>>;
}
// this works fine
boom(1);

//This runs fine setting limit to 1,2, or 3
3 => int limit;
for (0 => int i; i < limit; i++)
{
    boom(i);
}

/*
//  remove comments if you want to crash!
//This goes BOOM!  CRASH! 
4 => limit;
for (0 => int i; i < limit; i++)
{
    boom(i);
}
*/

This is fixed by either declaring the function as fun void boom or adding the line return 0; to the end of the function.

The code does not crash under OS X.

OS X 10.8.5 miniAudicle 1.3.0 ChucK 1.3.2.0

Windows 7 miniAudicle 1.3.1 ChucK 1.3.3.0

spencersalazar commented 10 years ago

This hasnt been tested on Windows yet, but the issue should be fixed as of https://github.com/ccrma/chuck/commit/50fad67d00cfbe2fbbb7e6c0a3e9a8c5c3d837e3.