LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 29123 - std::tuple compilation errors with implicit conversion constructors
Summary: std::tuple compilation errors with implicit conversion constructors
Status: RESOLVED FIXED
Alias: None
Product: libc++
Classification: Unclassified
Component: All Bugs (show other bugs)
Version: 3.9
Hardware: PC All
: P normal
Assignee: Eric Fiselier
URL:
Keywords:
: 34895 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-08-24 11:46 PDT by akotulski
Modified: 2017-10-09 17:50 PDT (History)
9 users (show)

See Also:
Fixed By Commit(s):


Attachments
compilation error message (3.46 KB, text/plain)
2016-08-24 11:46 PDT, akotulski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description akotulski 2016-08-24 11:46:14 PDT
Created attachment 17037 [details]
compilation error message

I encountered this error when trying to use libcxx from 3.9 release and trunk from around August 1st. The same code works with 3.8 release

Repro: compile following example with libc++:
clang -c -std=c++14 repro.cpp -stdlib=libc++

// repro.cpp
// this is minimized code from folly library
#include<tuple>
template<class Value>
struct Optional {
  // implicit
  Optional(const Value& newValue) {}
};

struct dynamic {
  // implicit
  template<class T> dynamic(T t);
};

Optional<std::tuple<dynamic>> get();

void test() { auto x = get(); }
Comment 1 Eric Fiselier 2016-08-24 13:34:04 PDT
Darn it.
Comment 2 Hans Wennborg 2016-08-24 22:53:15 PDT
Eric, can you give an assessment of the severity of this bug and how intrusive a fix might be?

At this stage in the 3.9 process (rc3 was just tagged), I'm reluctant to take patches for anything but regressions from earlier release candidates.
Comment 3 Eric Fiselier 2016-08-24 22:59:30 PDT
> Eric, can you give an assessment of the severity of this bug and how intrusive a fix might be?

It's a regression from 3.8 and tuple tends to get a lot of usage, and breakage is often noticed by many users. That's why I would like to fix this before 3.9.

The fix should hopefully be small. I'll give a more complete analysis tomorrow.
Comment 4 Eric Fiselier 2016-08-28 14:07:21 PDT
So this may be a Clang bug. It seems that GCC accepts the reproducer just fine. I still would like to see this fixed in Clang before 3.9 but that might be a harder change to make.
Comment 5 Eric Fiselier 2016-08-28 17:48:46 PDT
Attempted fix: https://reviews.llvm.org/D23978

The bug seems to be caused only when `__enable_implicit()` is defined as a constexpr function. Defining it as a alias template fixes the bug. I have no idea why this changes anything or why the original error is generated at all.
Comment 6 Hans Wennborg 2016-08-29 10:54:40 PDT
(In reply to comment #5)
> Attempted fix: https://reviews.llvm.org/D23978
> 
> The bug seems to be caused only when `__enable_implicit()` is defined as a
> constexpr function. Defining it as a alias template fixes the bug. I have no
> idea why this changes anything or why the original error is generated at all.

Richard, can you shed some light on why the proposed patch makes a difference here?
Comment 7 Hans Wennborg 2016-08-30 14:55:33 PDT
After speaking with Richard about this, it sounds like we don't have a lot of good options to choose from here (there seems to be both issues with Clang and the C++ standard library).

Taking Eric's D23978 is probably the least bad thing, doesn't make anything worse, and will fix this PR. So can we go ahead and land it?
Comment 8 Renato Golin 2016-08-30 15:15:39 PDT
I have no reservations, and Richard's word is good enough for me in this case. :)

We can change that on trunk later, if necessary.
Comment 9 Eric Fiselier 2016-12-08 21:57:47 PST
Update:

I choose not to fix this bug in libc++ for 3.9.0 for two reasons:

1. This was also caused by a Clang bug, which was fixed shortly after the 3.9.0 release and it has been applied to the upcoming 3.9.1 release. I didn't want to re-write large portions of std::tuple right before a release in order to avoid a Clang bug.
2. The reproducer has a cyclic SFINAE condition, and I would consider that UB.

Closing this bug as resolved fixed since it compiles with ToT clang.
Comment 10 Eric Fiselier 2017-10-09 17:50:00 PDT
*** Bug 34895 has been marked as a duplicate of this bug. ***
Comment 11 Eric Fiselier 2017-10-09 17:50:40 PDT
See https://reviews.llvm.org/D23999 for more information.