Bug 268329 - lang/gjs: fix build with clang/libc++ 15
Summary: lang/gjs: fix build with clang/libc++ 15
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: 265425
  Show dependency treegraph
 
Reported: 2022-12-12 13:53 UTC by Dimitry Andric
Modified: 2022-12-18 17:48 UTC (History)
0 users

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


Attachments
lang/gjs: fix build with clang/libc++ 15 (2.85 KB, patch)
2022-12-12 13:54 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 2022-12-12 13:53:54 UTC
During an exp-run for llvm 15 (see bug 265425), it turned out that lang/gjs failed to build with clang and libc++ 15:

  In file included from ../test/gjs-tests.cpp:11:
  In file included from /usr/include/c++/v1/random:1689:
  In file included from /usr/include/c++/v1/__random/discrete_distribution.h:18:
  In file included from /usr/include/c++/v1/numeric:167:
  In file included from /usr/include/c++/v1/functional:515:
  In file included from /usr/include/c++/v1/__functional/boyer_moore_searcher.h:24:
  In file included from /usr/include/c++/v1/array:127:
  In file included from /usr/include/c++/v1/algorithm:1851:
  In file included from /usr/include/c++/v1/__algorithm/ranges_sample.h:13:
  In file included from /usr/include/c++/v1/__algorithm/sample.h:18:
  /usr/include/c++/v1/__random/uniform_int_distribution.h:162:5: error: static assertion failed due to requirement '__libcpp_random_is_valid_inttype<char32_t>::value': IntType must be a supported integer type
      static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");
      ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../test/gjs-tests.cpp:71:16: note: in instantiation of template class 'std::uniform_int_distribution<char32_t>' requested here
          return std::uniform_int_distribution<T>(lowest_value)(gen);
                 ^
  ../test/gjs-tests.cpp:942:30: note: in instantiation of function template specialization 'Gjs::Test::get_random_number<char32_t>' requested here
      char32_t random_char32 = get_random_number<char32_t>();
                               ^

This is because std::uniform_int_distribution is only defined for strict integer types, such as short, int, etc. Use std::uniform_int_distribution<uint32_t> instead, and cast the result back to a char32_t.
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2022-12-12 13:54:22 UTC
Created attachment 238728 [details]
lang/gjs: fix build with clang/libc++ 15
Comment 2 commit-hook freebsd_committer freebsd_triage 2022-12-18 17:44:26 UTC
A commit in branch main references this bug:

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

commit 9f8385f9876a46d8566cd655062c8ba24efac2f5
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2022-12-12 13:49:23 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2022-12-18 17:34:13 +0000

    lang/gjs: fix build with libc++ 15

    During an exp-run for llvm 15 (see bug 265425), it turned out that
    lang/gjs failed to build with clang and libc++ 15:

      In file included from ../test/gjs-tests.cpp:11:
      In file included from /usr/include/c++/v1/random:1689:
      In file included from /usr/include/c++/v1/__random/discrete_distribution.h:18:
      In file included from /usr/include/c++/v1/numeric:167:
      In file included from /usr/include/c++/v1/functional:515:
      In file included from /usr/include/c++/v1/__functional/boyer_moore_searcher.h:24:
      In file included from /usr/include/c++/v1/array:127:
      In file included from /usr/include/c++/v1/algorithm:1851:
      In file included from /usr/include/c++/v1/__algorithm/ranges_sample.h:13:
      In file included from /usr/include/c++/v1/__algorithm/sample.h:18:
      /usr/include/c++/v1/__random/uniform_int_distribution.h:162:5: error: static assertion failed due to requirement '__libcpp_random_is_valid_inttype<char32_t>::value': IntType must be a supported integer type
          static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");
          ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../test/gjs-tests.cpp:71:16: note: in instantiation of template class 'std::uniform_int_distribution<char32_t>' requested here
              return std::uniform_int_distribution<T>(lowest_value)(gen);
                     ^
      ../test/gjs-tests.cpp:942:30: note: in instantiation of function template specialization 'Gjs::Test::get_random_number<char32_t>' requested here
          char32_t random_char32 = get_random_number<char32_t>();
                                   ^

    This is because std::uniform_int_distribution is only defined for strict
    integer types, such as short, int, etc. Use
    std::uniform_int_distribution<uint32_t> instead, and cast the result
    back to a char32_t.

    PR:             268329
    Approved by:    portmgr (tcberner)
    MFH:            2022Q4

 lang/gjs/files/patch-test_gjs-tests.cpp (new) | 11 +++++++++++
 1 file changed, 11 insertions(+)