Bug 271953

Summary: japanese/zinnia: fix build with clang 16
Product: Ports & Packages Reporter: Dimitry Andric <dim>
Component: Individual Port(s)Assignee: Dimitry Andric <dim>
Status: Closed FIXED    
Severity: Affects Some People CC: beyert, fernape
Priority: --- Flags: bugzilla: maintainer-feedback? (beyert)
Version: Latest   
Hardware: Any   
OS: Any   
Bug Depends on:    
Bug Blocks: 271047    
Attachments:
Description Flags
japanese/zinnia: fix build with clang 16 none

Description Dimitry Andric freebsd_committer freebsd_triage 2023-06-11 17:04:54 UTC
Since clang 16 (and gcc 11) the default C++ standard is now gnu++17.
Because japanese/zinnia's build infrastructure does not explicitly set
its C++ standard, this leads to an error:

  svm.cpp:50:10: error: no member named 'random_shuffle' in namespace 'std'
      std::random_shuffle(index.begin(), index.begin() + active_size);
      ~~~~~^

This is because std::random_shuffle has been removed from C++17. An
suitable replacement is std::shuffle, using a std::random_device in
combination with std::mt19937 as the random number engine.
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2023-06-11 17:05:13 UTC
Created attachment 242736 [details]
japanese/zinnia: fix build with clang 16
Comment 2 Fernando ApesteguĂ­a freebsd_committer freebsd_triage 2023-06-12 08:41:59 UTC
^Triage: reporter is committer, assign accordingly.

Builds fine in 12.4{amd64,i386}, 13.2amd64 and 14-current(ish) amd64.

LGTM!
Comment 3 commit-hook freebsd_committer freebsd_triage 2023-06-12 18:38:02 UTC
A commit in branch main references this bug:

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

commit abdd4cf0e5ab5f26b366d9ab86644ebaacd85624
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-06-11 17:01:12 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-06-12 18:36:01 +0000

    japanese/zinnia: fix build with clang 16

    Since clang 16 (and gcc 11) the default C++ standard is now gnu++17.
    Because japanese/zinnia's build infrastructure does not explicitly set
    its C++ standard, this leads to an error:

      svm.cpp:50:10: error: no member named 'random_shuffle' in namespace 'std'
          std::random_shuffle(index.begin(), index.begin() + active_size);
          ~~~~~^

    This is because std::random_shuffle has been removed from C++17. An
    suitable replacement is std::shuffle, using a std::random_device in
    combination with std::mt19937 as the random number engine.

    PR:             271953
    Approved by:    fernape
    MFH:            2023Q2

 japanese/zinnia/Makefile                  |  2 +-
 japanese/zinnia/files/patch-svm.cpp (new) | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)
Comment 4 Timothy Beyer 2023-06-13 06:28:13 UTC
sounds great, thanks, maintainer approved