The problem with the endless loop is in the function "smpAllocMsg". There gcc makes out of the while loop ("freeList == 0") an endless loop.
The problem with the line which is optimized away is in the smpSendMsgBroadcast, its the line "serviceMsg= msg". This problem can be avoided if I call another function (I tested printf) before the while loop (msg->refCount > 0). These 2 problems only occur if I use the "-O2" switch with "-O1" it works. What I do not understand is, why is gcc doing that, although I´m using the volatile keyword!? -- Summary: gcc optimizes line away/optimizes to an endless loop Product: gcc Version: 4.4.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: codemasterhs at yahoo dot de GCC host triplet: cygwin GCC target triplet: i586-elf http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42126