Bug 284167 - math/givaro: only declare std::bool_constant if it does not exist yet
Summary: math/givaro: only declare std::bool_constant if it does not exist yet
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Dimitry Andric
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-01-19 15:56 UTC by Dimitry Andric
Modified: 2025-01-19 18:57 UTC (History)
1 user (show)

See Also:
pi: maintainer-feedback+


Attachments
math/givaro: only declare std::bool_constant if it does not exist yet (2.24 KB, patch)
2025-01-19 16:00 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 2025-01-19 15:56:14 UTC
While doing test builds for bug 284159 (math/linbox), I ran into an
issue compiling against one of the math/givaro headers, with clang and
libc++ 19:

  /usr/local/include/givaro/random-integer.h:40:14: error: reference to 'bool_constant' is ambiguous
     40 |         std::bool_constant<_Exact_Size>::type _Exact_Size_t;
        |              ^
  /usr/include/c++/v1/__type_traits/integral_constant.h:42:1: note: candidate found by name lookup is 'std::__1::bool_constant'
     42 | using bool_constant = integral_constant<bool, __b>;
        | ^
  /usr/local/include/givaro/random-integer.h:16:5: note: candidate found by name lookup is 'std::bool_constant'
     16 |     using bool_constant = integral_constant<bool, B>;
        |     ^

The problem is that random-integer.h attempts to declare
std::bool_constant, even though libc++ headers already have this
template.

Conditionalize it on __cpp_lib_bool_constant [1], so it is only declared
when necessary (i.e. if somebody compiles against and older C++
library).

[1] https://en.cppreference.com/w/cpp/feature_test#cpp_lib_bool_constant
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2025-01-19 16:00:09 UTC
Created attachment 256810 [details]
math/givaro: only declare std::bool_constant if it does not exist yet
Comment 2 Kurt Jaeger freebsd_committer freebsd_triage 2025-01-19 16:25:25 UTC
(In reply to Dimitry Andric from comment #1)
Approved, please commit.
Comment 3 commit-hook freebsd_committer freebsd_triage 2025-01-19 18:11:18 UTC
A commit in branch main references this bug:

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

commit 238564b86a506b7ec6e8a3b7b6be7a423cb50337
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-01-19 15:56:44 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2025-01-19 18:09:20 +0000

    math/givaro: only declare std::bool_constant if it does not exist yet

    While doing test builds for bug 284159 (math/linbox), I ran into an
    issue compiling against one of the math/givaro headers, with clang and
    libc++ 19:

      /usr/local/include/givaro/random-integer.h:40:14: error: reference to 'bool_constant' is ambiguous
         40 |         std::bool_constant<_Exact_Size>::type _Exact_Size_t;
            |              ^
      /usr/include/c++/v1/__type_traits/integral_constant.h:42:1: note: candidate found by name lookup is 'std::__1::bool_constant'
         42 | using bool_constant = integral_constant<bool, __b>;
            | ^
      /usr/local/include/givaro/random-integer.h:16:5: note: candidate found by name lookup is 'std::bool_constant'
         16 |     using bool_constant = integral_constant<bool, B>;
            |     ^

    The problem is that random-integer.h attempts to declare
    std::bool_constant, even though libc++ headers already have this
    template.

    Conditionalize it on __cpp_lib_bool_constant [1], so it is only declared
    when necessary (i.e. if somebody compiles against and older C++
    library).

    [1] https://en.cppreference.com/w/cpp/feature_test#cpp_lib_bool_constant

    PR:             284167
    Approved by:    pi (maintainer)
    MFH:            2025Q1

 .../files/patch-src_kernel_integer_random-integer.h       | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2025-01-19 18:20:23 UTC
A commit in branch 2025Q1 references this bug:

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

commit 07795f50c324d1030d2339292eb4d7dafb14db19
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-01-19 15:56:44 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2025-01-19 18:17:55 +0000

    math/givaro: only declare std::bool_constant if it does not exist yet

    While doing test builds for bug 284159 (math/linbox), I ran into an
    issue compiling against one of the math/givaro headers, with clang and
    libc++ 19:

      /usr/local/include/givaro/random-integer.h:40:14: error: reference to 'bool_constant' is ambiguous
         40 |         std::bool_constant<_Exact_Size>::type _Exact_Size_t;
            |              ^
      /usr/include/c++/v1/__type_traits/integral_constant.h:42:1: note: candidate found by name lookup is 'std::__1::bool_constant'
         42 | using bool_constant = integral_constant<bool, __b>;
            | ^
      /usr/local/include/givaro/random-integer.h:16:5: note: candidate found by name lookup is 'std::bool_constant'
         16 |     using bool_constant = integral_constant<bool, B>;
            |     ^

    The problem is that random-integer.h attempts to declare
    std::bool_constant, even though libc++ headers already have this
    template.

    Conditionalize it on __cpp_lib_bool_constant [1], so it is only declared
    when necessary (i.e. if somebody compiles against and older C++
    library).

    [1] https://en.cppreference.com/w/cpp/feature_test#cpp_lib_bool_constant

    PR:             284167
    Approved by:    pi (maintainer)
    MFH:            2025Q1

    (cherry picked from commit 238564b86a506b7ec6e8a3b7b6be7a423cb50337)

 .../files/patch-src_kernel_integer_random-integer.h       | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)