outcome icon indicating copy to clipboard operation
outcome copied to clipboard

Work around msvc bug

Open Marc-Aldorasi-Imprivata opened this issue 1 year ago • 5 comments

Outcome triggers a SFINAE bug in MSVC by attempting to default construct ErrorCondEnum in a type constraint. This patch works around it by using std::declval instead.

Reproduction source file (also on godbolt)

#include <outcome.hpp>

struct inner {
	explicit inner(int);
	inner(inner &&);
};
struct middle {
	inner inn;
	template <class... Args>
	explicit middle(Args &&...args) : inn(static_cast<Args &&>(args)...) {}
	middle(middle &&);
};
struct outer {
	middle mid;
	int i = 0;
};

namespace o = OUTCOME_V2_NAMESPACE;

o::result<outer> func(outer &&out) {
	return static_cast<outer &&>(out);
}

Marc-Aldorasi-Imprivata avatar Sep 24 '24 16:09 Marc-Aldorasi-Imprivata

Thanks for the report! I've upvoted the DevCom ticket. However, I think we should hold back on merging the fix until the MSVC v17.12 release is imminent as the MSVC bug might be fixed in one of the next previews. You should mention in the DevCom ticket that this affects outcome (and therefore a boost library) and link to this pull request. This usually moves such tickets further up the priority list.

BurningEnlightenment avatar Sep 24 '24 20:09 BurningEnlightenment

Also note we can't use declval from the STL, as it would drag in an include we don't currently bring in.

I believe there is a alternative declval somewhere around. In any case, don't be merging this until it gets fixed up.

ned14 avatar Sep 24 '24 20:09 ned14

basic_result already uses std::declval in the next constructor (line 457)

Marc-Aldorasi-Imprivata avatar Sep 25 '24 15:09 Marc-Aldorasi-Imprivata

basic_result already uses std::declval in the next constructor (line 457)

Sigh. This is why https://github.com/ned14/outcome/issues/248 needs implementing.

Thanks for mentioning that, it must have slipped in at some point.

ned14 avatar Sep 25 '24 16:09 ned14

The MSVC devcom ticket has been marked as fixed, therefore I assume that this bug won't make it into a VS production release.

BurningEnlightenment avatar Oct 13 '24 21:10 BurningEnlightenment