[Live-devel] live streaming media server bug report

Ross Finlayson finlayson at live555.com
Thu Aug 30 00:44:51 PDT 2012


>> complains about the following statement:
>> ----
>> result = *(float*)&resultAsUnsigned;

No, this compiler warning message does not indicate a bug in the code.  "resultAsUnsigned"  is a 4-byte value that stores a 'float'; it is not an unsigned value that gets converted to a float.

>> This little snippet, and it's compiled output, illustrate the problem:

No, a more accurate 'snippet', which illustrates what the code really does, would be:

void func(float &f)
{
  float val = 3.0;
   unsigned *vptr = (unsigned*)&val;

   unsigned resultAsUnsigned = *vptr; // a 4-byte value that stores a 'float'
   f = *(float*)&resultAsUnsigned;
}

(and then "main()" as you originally wrote it)

If you can suggest an alternative coding that eliminates your compiler warning, then that would be great.  But the code - as it stands - is not in error.


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/20120830/92c10210/attachment.html>


More information about the live-devel mailing list