[Live-devel] live streaming media server bug report

Ross Finlayson finlayson at live555.com
Thu Sep 6 16:51:34 PDT 2012


While I doubt that - in practice - a compiler would generate incorrect code in this case, I agree that it's a possibility unless we compile with "-fno-strict-aliasing".  But I don't want to do that, because it could make the whole of the code less efficient.  (And changing the Makefiles to compile only this one file - "MatroskaFileParser.cpp" - with that flag would be messy.)

However, reading through some of the comments at the bottom of <http://labs.qt.nokia.com/2011/06/10/type-punning-and-strict-aliasing/>, it's noted that   one can get around strict aliasing restrictions by using "memcpy()".  So, with this in mind, try the following alternative implementation of "MatroskaFileParser::parseEBMLVal_float()", and let us know if it makes your compiler happy:


Boolean MatroskaFileParser::parseEBMLVal_float(EBMLDataSize& size, float& result) {
  unsigned resultAsUnsigned;
  if (!parseEBMLVal_unsigned(size, resultAsUnsigned)) return False;

  if (sizeof result != sizeof resultAsUnsigned) return False;
  memcpy(&result, &resultAsUnsigned, sizeof result);
  return True;
}


Ross Finlayson
Live Networks, Inc.
http://www.live555.com/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20120906/c5bfdbff/attachment.html>


More information about the live-devel mailing list