[Live-devel] live streaming media server bug report

owen at metamachine.com owen at metamachine.com
Wed Aug 29 16:09:01 PDT 2012


> Hi.
>
> I downloaded live.2012.08.29.tar.gz a few minutes ago, and built in on my
> linux box*.
>
> I saw several warnings issued by the compiler.
>
> I've been looking closely at each, and I think there's an actual problem
> with one of them.
> ----
> c++ -c -Iinclude -I../UsageEnvironment/include -I../groupsock/include -I.
> -O2 -DSOCKLEN_T=socklen_t -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64
> -Wall -DBSD=1 MatroskaFileParser.cpp
> MatroskaFileParser.cpp: In member function ‘Boolean
> MatroskaFileParser::parseEBMLVal_float(EBMLDataSize&, float&)’:
> MatroskaFileParser.cpp:1138:26: warning: dereferencing type-punned pointer
> will break strict-aliasing rules [-Wstrict-aliasing]
> MatroskaFileParser.cpp:1145:34: warning: dereferencing type-punned pointer
> will break strict-aliasing rules [-Wstrict-aliasing]
> c++ -c -Iinclude -I../UsageEnvironment/include -I../groupsock/include -I.
> -O2 -DSOCKLEN_T=socklen_t -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64
> -Wall -DBSD=1 EBMLNumber.cpp
> ----
>
> complains about the following statement:
> ----
> result = *(float*)&resultAsUnsigned;
>
> ----
> result is a float passed in by reference, and resultAsUnsigned is an
> unsigned int.
>
> This little snippet, and it's compiled output, illustrate the problem:
> ----
> #include <iostream>
>
> using namespace std;
>
> void func(float &f)
> {
>     unsigned val = 3;
>     unsigned *vptr = &val;
>     f = *(float*)vptr;
> }
>
> int main(int ac, char **av)
> {
>     float f;
>
>     func(f);
>
>     cout << "f == " << f << endl;
>
>     return 0;
> }
> --
> owen at owen ~/src/tests $ ./test_unsigned_float
> f == 4.2039e-45
> owen at owen ~/src/tests $
> --
> ----
> Note that the output should have been 3.0, but to get that, the code would
> have to be changed to:
> ----
>     f = (float)*vptr;
> ----
>
>
>   // Wally
>
>
> * Linux Mint 13 32-bit; gcc 4.6; c++ lib 4.6.3
>




More information about the live-devel mailing list