The bug is known to occur with the following versions: - gcc version 4.3.2 20081105 (Red Hat 4.3.2-7) (GCC) - g++ (Ubuntu 4.3.2-2ubuntu11) 4.3.3 20090111 (prerelease)
The symptom of the bug is that when you use -O2 htons(short) returns 'unsigned int' (32 bit) rather then the expected 16bit value. With no optimization it returns the correct 16bit. I'll attach a testcase. -- Summary: Optimizer changes return from htons(uint16) Product: gcc Version: 4.3.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: strk at keybit dot net http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39623