Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Type pretty printing for auto deduced non-type template parameter (P0127R2) in diagnostics can be confusing #41497

Open Quuxplusone opened 5 years ago

Quuxplusone commented 5 years ago
Bugzilla Link PR42527
Status NEW
Importance P enhancement
Reported by Piotr Rak (piotr.rak@gmail.com)
Reported on 2019-07-06 16:18:22 -0700
Last modified on 2019-07-07 10:01:10 -0700
Version trunk
Hardware PC Linux
CC blitzrakete@gmail.com, dblaikie@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments confusing_P0127R2_pretty_printing.cc (488 bytes, text/x-c++src)
Blocks
Blocked by
See also
Created attachment 22201
Test case

Since there is no type information about type deduced for auto placeholder in
non-type template parameter while pretty printing in diag, error message can
confuse user.

Please consider code:

template <typename, typename> struct is_same           { enum { value = false};
};
template <typename Ty_>       struct is_same<Ty_, Ty_> { enum { value = true };
};

template <auto> struct nonty_auto {};

using unsigned_auto_t   = nonty_auto< unsigned(0)>;
using signed_auto_t     = nonty_auto< int(0) >;

static_assert(is_same<unsigned_auto_t, signed_auto_t>::value, "might confuse
user");

That will result in error message:

confusing_P0127R2_pretty_printing.cc:12:1: error: static_assert failed due to
requirement 'is_same<nonty_auto<0>, nonty_auto<0> >::value' "might confuse user"
static_assert(is_same<unsigned_auto_t, signed_auto_t>::value, "might confuse
user");

Based on that user is not able distinguish between nonty_auto instantiated with
signed and unsigned literal 0.
Quuxplusone commented 5 years ago

Attached confusing_P0127R2_pretty_printing.cc (488 bytes, text/x-c++src): Test case