Sorry, I did not report correctly. There was two calls to function SetTaskFPUContext, one with and one without the '&'. The correct one passed the correct address, the other first copied the contents from FPUContexts[0] to the temporary variable and then passed the address of the temporary to the function. It did not copy the contents of the temporary back to the original variable after the call, though. Even so, that is not the correct behavior. At least a warning should be issued, but in my opinion that should be an error, period. Cheers, Isaac Em 13/03/2016 10:52, Isaac Marino Bavaresco escreveu: > Dear All, > > > I'm working on my RTOS and it seems that I found a bug in XC32. > > I have a function declared as: > int SetTaskFPUContext( context_t *Task, fpucontext_t *FPUContext ) > > fpucontext_t is: > typedef struct { ... } fpucontext_t; > > Then I have: > > fpucontext_t FPUContexts[2]; > > void TaskRX( void *param ) > { > ... > SetTaskFPUContext( NewTask, FPUContexts[0] ); // The obvious error > is that it should be "&FPUContexts[0]" > ... > } > > > I would expect a compiler error, but the compiler silently allocated > space for one instance of the struct on the stack (264 bytes, producing > a stack overflow) and passed the correct address of FPUContexts[0] to > function SetTaskFPUContext. The temporary variable on stack was > allocated for nothing. > > After adding the missing '&', everything worked correctly. > > I consider myself experienced in C, it doesn't seem correct behavior. > What do you think? > > > Cheers, > > Isaac > > > --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .