oneTBB icon indicating copy to clipboard operation
oneTBB copied to clipboard

Fix the implicit deduction guides on Apple LLVM 10.0.0

Open kboyarinov opened this issue 3 years ago • 0 comments

Description

Fixing the issue with concurrent_unordered_map Class Template Argument deduction on MacOS with Apple LLVM 10.0.0 The issue is that the implicit deduction guide for copy/move constructor with extra allocator_type argument is not working correctly and results in a substitution failure with the unclear logs.

The short reproducer for the issue:

#define WITH_BOOL 0

#if WITH_BOOL
template <typename T, typename Allocator, bool Allow>
#else
template <typename T, typename Allocator>
#endif
struct Traits {
    using allocator_type = Allocator;
};

template <typename TraitsType>
struct base {
    using allocator_type = typename TraitsType::allocator_type;
    base() = default;
    base(const base&, const allocator_type&) {}
};

template <typename T, typename Allocator = std::allocator<T>>
#if WITH_BOOL
struct derived : base<Traits<T, Allocator, false>> {
#else
struct derived : base<Traits<T, Allocator>> {
#endif
private:
#if WITH_BOOL
    using base_type = base<Traits<T, Allocator , false>>;
#else
    using base_type = base<Traits<T, Allocator>>;
#endif
public:
    using allocator_type = typename base_type::allocator_type;
    using base_type::base_type;

    derived() = default;
    derived(const derived& other, const allocator_type& alloc) : base_type(other, alloc) {}
};

int main() {
    std::allocator<int> alloc;
    derived<int> d1;

    derived d2(d1, alloc);
}

The problem is actually caused by the last boolean template parameter for Traits. If there is no such parameter, the code above works fine. The issue is not reproduced on the Linux LLVM configurations as well as on the elder versions of Apple LLVM.

The fix is to provide explicit deduction guide for copy/move constructor with allocator only for the affected Apple LLVM compiler version.

Fixes # - issue number(s) if exists

  • [ ] - git commit message contains an appropriate signed-off-by string (see CONTRIBUTING.md for details)

Type of change

Choose one or multiple, leave empty if none of the other choices apply

Add a respective label(s) to PR if you have permissions

  • [x] bug fix - change that fixes an issue
  • [ ] new feature - change that adds functionality
  • [ ] tests - change in tests
  • [ ] infrastructure - change in infrastructure and CI
  • [ ] documentation - documentation update

Tests

  • [ ] added - required for new features and some bug fixes
  • [x] not needed

Documentation

  • [ ] updated in # - add PR number
  • [ ] needs to be updated
  • [x] not needed

Breaks backward compatibility

  • [ ] Yes
  • [x] No
  • [ ] Unknown

Notify the following users

List users with @ to send notifications

Other information

kboyarinov avatar Sep 08 '22 11:09 kboyarinov