Bug 272029 - multimedia/phonon: fix build with clang 16
Summary: multimedia/phonon: fix build with clang 16
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-kde (group)
URL:
Keywords:
Depends on:
Blocks: 271047
  Show dependency treegraph
 
Reported: 2023-06-16 18:56 UTC by Dimitry Andric
Modified: 2023-08-05 15:03 UTC (History)
2 users (show)

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


Attachments
multimedia/phonon: fix build with clang 16 (3.01 KB, patch)
2023-06-16 18:57 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 2023-06-16 18:56:50 UTC
Clang 16 has a new error about integer values being outside the valid
range for enum types, which shows up when building multimedia/phonon:

  /wrkdirs/usr/ports/multimedia/phonon/work/.build/phonon/experimental/phonon4qt5experimental_autogen/EWIEGA46WW/../../../../../phonon-4.11.1/phonon/experimental/visualization.h:45:27: error: integer value 4294967294 is outside the valid range of values [0, 7] for the enumeration type 'ObjectDescriptionType' [-Wenum-constexpr-conversion]
  typedef ObjectDescription<static_cast<Phonon::ObjectDescriptionType>(VisualizationType)> VisualizationDescription;
                            ^
  /wrkdirs/usr/ports/multimedia/phonon/work/.build/phonon/experimental/phonon4qt5experimental_autogen/EWIEGA46WW/../../../../../phonon-4.11.1/phonon/experimental/visualization.h:46:32: error: integer value 4294967294 is outside the valid range of values [0, 7] for the enumeration type 'ObjectDescriptionType' [-Wenum-constexpr-conversion]
  typedef ObjectDescriptionModel<static_cast<Phonon::ObjectDescriptionType>(VisualizationType)> VisualizationDescriptionModel;
                                 ^
  /wrkdirs/usr/ports/multimedia/phonon/work/phonon-4.11.1/phonon/objectdescription.h:189:41: error: integer value 4294967294 is outside the valid range of values [0, 7] for the enumeration type 'ObjectDescriptionType' [-Wenum-constexpr-conversion]
          static inline ObjectDescription<T> fromIndex(int index) { //krazy:exclude=inline
                                          ^
  /wrkdirs/usr/ports/multimedia/phonon/work/phonon-4.11.1/phonon/objectdescription.h:260:45: error: integer value 4294967294 is outside the valid range of values [0, 7] for the enumeration type 'ObjectDescriptionType' [-Wenum-constexpr-conversion]
          friend class ObjectDescriptionModel<T>;
                                              ^

This is because enum ObjectDescriptionType only has 6 members, and
therefore only gets 3 bits allocated by default. In that case, values
like 4294967294 (0xfffffffe) do not fit in it.

Work around the problem by declaring enum ObjectDescriptionType to
explicitly be of type unsigned, so it can fit 32 bits.
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2023-06-16 18:57:15 UTC
Created attachment 242814 [details]
multimedia/phonon: fix build with clang 16
Comment 3 Dimitry Andric freebsd_committer freebsd_triage 2023-06-24 14:34:27 UTC
Note that clang upstream plans to make -Wenum-constexpr-conversion a hard error in the future (i.e it cannot be turned off anymore), so at some point actually fixing the problem should be done. In that case, the above patch still applies. :)
Comment 4 Raphael Kubo da Costa freebsd_committer freebsd_triage 2023-07-14 12:12:10 UTC
For the record, upstream ended up doing the same thing that's been done in https://cgit.freebsd.org/ports/commit/?id=83e1d12fd0838b9cb38867f54bef20790e05b3af

I've posted a comment to https://invent.kde.org/libraries/phonon/-/merge_requests/13 pointing out what dim's mentioned here, hopefully this leads to a proper fix there.
Comment 5 Dimitry Andric freebsd_committer freebsd_triage 2023-07-14 12:14:09 UTC
(In reply to Raphael Kubo da Costa from comment #4)
Point them to https://reviews.llvm.org/D150226, where it seems like the possibility of disabling this error is going to go away after clang 17.
Comment 6 Dimitry Andric freebsd_committer freebsd_triage 2023-07-16 13:19:09 UTC
I have submitted https://invent.kde.org/libraries/phonon/-/merge_requests/16 for the future-proof fix.
Comment 7 commit-hook freebsd_committer freebsd_triage 2023-08-05 15:03:42 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=73b6e876a9d3bb44fb7560c5efd99f9fe5f334b7

commit 73b6e876a9d3bb44fb7560c5efd99f9fe5f334b7
Author:     Raphael Kubo da Costa <rakuco@FreeBSD.org>
AuthorDate: 2023-08-05 15:01:50 +0000
Commit:     Raphael Kubo da Costa <rakuco@FreeBSD.org>
CommitDate: 2023-08-05 15:03:07 +0000

    multimedia/phonon: Switch to upstream's fix for clang 16 build issues

    Instead of passing a compiler flag to work around a clang 16 build
    issue, adopt the fix that dim@ landed upstream that fixes the code in
    question.

    PR:                     272029
    Approved by:            kde (arrowd)
    Differential Revision:  https://reviews.freebsd.org/D41307

 multimedia/phonon/Makefile                         |  9 ++----
 ...a3eb81bcbc730e44c27a0d060a85cf9213d.patch (new) | 36 ++++++++++++++++++++++
 2 files changed, 38 insertions(+), 7 deletions(-)