[SPCA] Fix various errors

This commit is contained in:
2026-01-23 10:33:49 +01:00
parent b86fd00a60
commit 25b3381294
15 changed files with 36 additions and 23 deletions

View File

@@ -29,11 +29,11 @@ int get_user_input_int( char prompt[] ) {
printf( "Hello World\n" );
}
// Inversed while loop (executes at least once)
// Inverted while loop (executes at least once)
do {
input_data -= 1;
input_data_copy -= 1;
printf( "Bye World\n" );
if ( input_data_copy == 0 )
if ( input_data_copy == 10 )
goto this_is_a_label;
} while ( input_data_copy > 1 );

View File

@@ -30,6 +30,7 @@ int main( int argc, char *argv[] ) {
assert( arr == &( arr[ 0 ] ) ); // Evaluates to true
int new_arr[ 3 ] = arr; // Compile time error (cannot use other array as initializer)
int *new_arr_p = &arr[ 0 ]; // This works
void *t;
a_function( &get_user_input_int, c_arr );

View File

@@ -2,7 +2,7 @@
int main( int argc, char **argv ) {
int a[ 2 ];
int *b = malloc( 2 * sizeof( int ) ), *c;
int *b = (int *) malloc( 2 * sizeof( int ) ), *c;
a[ 2 ] = 5; // assign past the end of an array
b[ 0 ] += 2; // assume malloc zeroes out memory
c = b + 3; // mess up your pointer arithmetic

View File

@@ -35,6 +35,6 @@ struct coroutine *co_new( co_start_fn *start, void *ctxt ) {
co->start = start;
co->arg = ctxt;
setjmp( co->env );
co->env[ 0 ].__jmpbuf[ 6 ] = ( (uint64_t) ( co->stack ) + CORO_STACK_SIZE ); // Machine specific
co->env[ 0 ].__jmpbuf[ 7 ] = ( (uint64_t) ( start_cl ) ); // Machine specific
co->env[ 0 ].__jmpbuf[ 6 ] = ( (uint64_t) ( co->stack ) + CORO_STACK_SIZE );
co->env[ 0 ].__jmpbuf[ 7 ] = ( (uint64_t) ( start_cl ) ); // Both lines machine specific
}