New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

taglib: fix test build failure on powerpc/c++11 #834

Merged
merged 1 commit into from Sep 19, 2017

Conversation

Projects
None yet
2 participants
@trofi
Contributor

trofi commented Sep 17, 2017

powerpc is a platform with 'char' == 'unsigned char'.
As a result '-1' is not expressible in char and build fails as:

    # '-funsigned-char' to force test build failure on other platforms
    $ cmake .. -DBUILD_TESTS=YES -DCMAKE_CXX_FLAGS="-O2 -funsigned-char" -DCMAKE_C_FLAGS="-O2 -funsigned-char"
    ...
    $ make check
    tests/test_synchdata.cpp: In member function 'void TestID3v2SynchData::testToUIntBroken()':
    tests/test_synchdata.cpp:78:33: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
     char data[] = { 0, 0, 0, -1 };
                                 ^

The fix is to expliticly cast -1 to 'char'.

Signed-off-by: Sergei Trofimovich slyfox@gentoo.org

@sbooth sbooth self-assigned this Sep 17, 2017

@sbooth sbooth added the minor label Sep 17, 2017

@sbooth

This comment has been minimized.

Show comment
Hide comment
@sbooth

sbooth Sep 18, 2017

Contributor

Thanks for this. I have one stylistic nitpick: TagLib code typically doesn't have () around the casted value for C-style casts (e.g. (char)-1 instead of (char)(-1). If you will remove those I'll merge this PR.

Contributor

sbooth commented Sep 18, 2017

Thanks for this. I have one stylistic nitpick: TagLib code typically doesn't have () around the casted value for C-style casts (e.g. (char)-1 instead of (char)(-1). If you will remove those I'll merge this PR.

taglib: fix test build failure on powerpc/c++11
powerpc is a platform with 'char' == 'unsigned char'.
As a result '-1' is not expressible in char and build fails as:

```
    # '-funsigned-char' to force test build failure on other platforms
    $ cmake .. -DBUILD_TESTS=YES -DCMAKE_CXX_FLAGS="-O2 -funsigned-char" -DCMAKE_C_FLAGS="-O2 -funsigned-char"
    ...
    $ make check
    tests/test_synchdata.cpp: In member function 'void TestID3v2SynchData::testToUIntBroken()':
    tests/test_synchdata.cpp:78:33: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
     char data[] = { 0, 0, 0, -1 };
                                 ^
```

The fix is to expliticly cast -1 to 'char'.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
@trofi

This comment has been minimized.

Show comment
Hide comment
@trofi

trofi Sep 18, 2017

Contributor

Got it. Dropped braces around -1.

Contributor

trofi commented Sep 18, 2017

Got it. Dropped braces around -1.

@sbooth sbooth merged commit 0b583ba into taglib:master Sep 19, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@sbooth

This comment has been minimized.

Show comment
Hide comment
@sbooth

sbooth Sep 19, 2017

Contributor

Thanks!

Contributor

sbooth commented Sep 19, 2017

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment