News for hackers. Stuff that matters.
Re:GCC: the impressive and the disappointing by ajg1977 on Saturday March 05, 2011 @01:06PM (#2291927)
unions are well known for scaring compilers away from many types of optimizations when encountered. For example, if you're writing a SIMD vector class then pretty much the worst thing you can do is put the SIMD data type in a union with a float array.
Re:GCC: the impressive and the disappointing by haberman on Saturday March 05, 2011 @03:05PM (#2292222)
The union is irrelevant, even with a union the compiler eliminated the branch in another test I ran where both functions had the same prototype. I'm on an iPad at the moment so can't verify, but I'd be willing to bet that exactly the same code would be generated if the two function pointers were passed as separate parameters (ie not in a union)