Symbian
Symbian OS Library

FAQ-0521 KERN-EXEC 3 When Passing C++ bool Parameters on MARM

[Index][spacer] [Previous] [Next]



 

Classification: C++ Category: Utilities & Build Tools
Created: 09/21/2000 Modified: 09/01/2001
Number: FAQ-0521
Platform: ER5

Question:
KERN-EXEC 3 When Passing C++ bool Parameters on MARM

Answer:
Passing a bool under MARM can cause problems due to a bug in the GCC ARM compiler that comes with the C++ SDK. GCC will pass the first 4 parameters to a function in registers (or less if they are more than 4 bytes in size), and the remainder will be placed on the stack. GCC stores a bool object in 1 byte, but makes a mistake when passing a bool as one of these stacked parameters - instead of decrementing the stack pointer by 4 it only decrements it by 1 when passing the bool.

That is basically guaranteed to cause an alignment fault a few instructions later when the stack pointer is used again - and that exception generates a KERN-EXEC 3 panic.

You can avoid this bug in GCC by passing the boolean value in any integral type instead of bool.