https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105672

            Bug ID: 105672
           Summary: Print note when unable to convert between types with
                    the same name but different scopes
           Product: gcc
           Version: 12.1.1
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

I spent far too long confused by this error:

vt.C:276:15: error: conversion from 'std::tuple<int, double,
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >
>' to non-scalar type 'tuple<int, float, std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > >' requested
  276 |     make_tuple(17, 2.718281828, std::string("Fun"));
      |     ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


The problem is that one type is std::tuple<...> and the other is ::tuple<...>
but the distinction is not very obvious in the error.

Could we add a note for ill-formed conversions between two types that have the
same name, to make it more obvious that they're defined in different scopes?

Maybe:

<error loc>:<col>: note: tuple and std::tuple are not the same type
<decl1 loc>:<col>: note: tuple define here
<decl2 loc>:<col>: note: std::tuple define here

Reply via email to