Bug 281477 - audio/libaudiofile: fix build with clang 19, enable tests
Summary: audio/libaudiofile: fix build with clang 19, enable tests
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-gnome (Nobody)
URL:
Keywords:
Depends on:
Blocks: 280562
  Show dependency treegraph
 
Reported: 2024-09-13 09:11 UTC by Dimitry Andric
Modified: 2024-09-28 09:51 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (gnome)


Attachments
audio/libaudiofile: fix build with clang 19, enable tests (6.40 KB, patch)
2024-09-13 09:12 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer freebsd_triage 2024-09-13 09:11:22 UTC
Clang 19 has become more strict about initialization with undefined
behavior, resulting in errors similar to:

  ./SimpleModule.h:126:40: error: in-class initializer for static data member is not a constant expression
    126 |         static const int kMinSignedValue = -1 << kScaleBits;
        |                                            ~~~^~~~~~~~~~~~~
  ./SimpleModule.h:176:22: note: in instantiation of template class 'signConverter<kInt8>' requested here
    176 |                 transform<typename signConverter<Format>::signedToUnsigned>(src, dst, count);
        |                                    ^
  ./SimpleModule.h:183:5: note: in instantiation of function template specialization 'ConvertSign::convertSignedToUnsigned<kInt8>' requested here
    183 |                                 convertSignedToUnsigned<kInt8>(src, dst, count);
        |                                 ^

This is because left-shifting negative values is undefined. Replace -1
with ~0u which results in the expected value.

While here, add a few other patches to remove warnings about undefined
left-shifts, and add support for the "make test" target.
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2024-09-13 09:12:38 UTC
Created attachment 253535 [details]
audio/libaudiofile: fix build with clang 19, enable tests
Comment 2 commit-hook freebsd_committer freebsd_triage 2024-09-28 09:48:14 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=7955b1d7ec787bf13f2cfea75e9355a3f3e91a53

commit 7955b1d7ec787bf13f2cfea75e9355a3f3e91a53
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-09-13 09:11:45 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-09-28 09:43:47 +0000

    audio/libaudiofile: fix build with clang 19, enable tests

    Clang 19 has become more strict about initialization with undefined
    behavior, resulting in errors similar to:

      ./SimpleModule.h:126:40: error: in-class initializer for static data member is not a constant expression
        126 |         static const int kMinSignedValue = -1 << kScaleBits;
            |                                            ~~~^~~~~~~~~~~~~
      ./SimpleModule.h:176:22: note: in instantiation of template class 'signConverter<kInt8>' requested here
        176 |                 transform<typename signConverter<Format>::signedToUnsigned>(src, dst, count);
            |                                    ^
      ./SimpleModule.h:183:5: note: in instantiation of function template specialization 'ConvertSign::convertSignedToUnsigned<kInt8>' requested here
        183 |                                 convertSignedToUnsigned<kInt8>(src, dst, count);
            |                                 ^

    This is because left-shifting negative values is undefined. Replace -1
    with ~0u which results in the expected value.

    While here, add a few other patches to remove warnings about undefined
    left-shifts, and add support for the "make test" target.

    PR:             281477
    Approved by:    maintainer timeout (2 weeks)
    MFH:            2024Q3

 audio/libaudiofile/Makefile                        |  3 +++
 audio/libaudiofile/files/patch-gtest_gtest.h (new) | 11 ++++++++
 ...patch-libaudiofile_modules_SimpleModule.h (new) | 11 ++++++++
 .../files/patch-test_FloatToInt.cpp (new)          | 11 ++++++++
 .../files/patch-test_IntToFloat.cpp (new)          | 11 ++++++++
 audio/libaudiofile/files/patch-test_NeXT.cpp (new) | 29 ++++++++++++++++++++++
 audio/libaudiofile/files/patch-test_Sign.cpp (new) | 20 +++++++++++++++
 7 files changed, 96 insertions(+)
Comment 3 commit-hook freebsd_committer freebsd_triage 2024-09-28 09:49:19 UTC
A commit in branch 2024Q3 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=1a4cfe7f1ee1ce76987f1455d361032fe456d081

commit 1a4cfe7f1ee1ce76987f1455d361032fe456d081
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-09-13 09:11:45 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-09-28 09:48:23 +0000

    audio/libaudiofile: fix build with clang 19, enable tests

    Clang 19 has become more strict about initialization with undefined
    behavior, resulting in errors similar to:

      ./SimpleModule.h:126:40: error: in-class initializer for static data member is not a constant expression
        126 |         static const int kMinSignedValue = -1 << kScaleBits;
            |                                            ~~~^~~~~~~~~~~~~
      ./SimpleModule.h:176:22: note: in instantiation of template class 'signConverter<kInt8>' requested here
        176 |                 transform<typename signConverter<Format>::signedToUnsigned>(src, dst, count);
            |                                    ^
      ./SimpleModule.h:183:5: note: in instantiation of function template specialization 'ConvertSign::convertSignedToUnsigned<kInt8>' requested here
        183 |                                 convertSignedToUnsigned<kInt8>(src, dst, count);
            |                                 ^

    This is because left-shifting negative values is undefined. Replace -1
    with ~0u which results in the expected value.

    While here, add a few other patches to remove warnings about undefined
    left-shifts, and add support for the "make test" target.

    PR:             281477
    Approved by:    maintainer timeout (2 weeks)
    MFH:            2024Q3

    (cherry picked from commit 7955b1d7ec787bf13f2cfea75e9355a3f3e91a53)

 audio/libaudiofile/Makefile                        |  3 +++
 audio/libaudiofile/files/patch-gtest_gtest.h (new) | 11 ++++++++
 ...patch-libaudiofile_modules_SimpleModule.h (new) | 11 ++++++++
 .../files/patch-test_FloatToInt.cpp (new)          | 11 ++++++++
 .../files/patch-test_IntToFloat.cpp (new)          | 11 ++++++++
 audio/libaudiofile/files/patch-test_NeXT.cpp (new) | 29 ++++++++++++++++++++++
 audio/libaudiofile/files/patch-test_Sign.cpp (new) | 20 +++++++++++++++
 7 files changed, 96 insertions(+)