public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101477] New: Wrong location for unexpanded parameter pack in function template
@ 2021-07-16 20:33 redi at gcc dot gnu.org
  2021-07-16 20:34 ` [Bug c++/101477] " redi at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2021-07-16 20:33 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101477
           Summary: Wrong location for unexpanded parameter pack in
                    function template
           Product: gcc
           Version: 12.0
            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: ---

template<typename... Elements>
class tuple
{ };

template<typename... Elements>
tuple<Elements>
get(const tuple<Elements...>& t)
{
  return t;
}

The error shows the wrong location:

t2.C:7:30: error: parameter packs not expanded with '...':
    7 | get(const tuple<Elements...>&)
      |                              ^
t2.C:7:30: note:         'Elements'

This case is especially confusing because the caret *almost* points to a
location where the pack *is* expanded, making it harder to spot the real
problem on the line above.

It should be:

t2.C:7:30: error: parameter packs not expanded with '...':
    6 | tuple<Elements>
      |       ^~~~~~~~
t2.C:7:30: note:         'Elements'

Even better would be to give a fix-it hint suggesting to add the ... after
Element, although that might be counterproductive sometimes. For example, in
this case the compiler probably won't guess where to put the ...

template<typename... Elements>
std::conjunction<is_const<Elements>>
get(const tuple<Elements...>& t)
{
  return t;
}

The user probably wants std::conjunction<is_const<Elements>...> not
std::conjunction<is_const<Elements...>>.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/101477] Wrong location for unexpanded parameter pack in function template
  2021-07-16 20:33 [Bug c++/101477] New: Wrong location for unexpanded parameter pack in function template redi at gcc dot gnu.org
@ 2021-07-16 20:34 ` redi at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2021-07-16 20:34 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-07-16
           See Also|                            |https://bugs.llvm.org/show_
                   |                            |bug.cgi?id=51118
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-16 20:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-16 20:33 [Bug c++/101477] New: Wrong location for unexpanded parameter pack in function template redi at gcc dot gnu.org
2021-07-16 20:34 ` [Bug c++/101477] " redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).