public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101792] New: Compiling access to templated parent object fails with unrelated message: invalid use of 'auto'
@ 2021-08-05 19:04 serpent7776 at gmail dot com
  2021-08-05 20:22 ` [Bug c++/101792] " redi at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: serpent7776 at gmail dot com @ 2021-08-05 19:04 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101792
           Summary: Compiling access to templated parent object fails with
                    unrelated message: invalid use of 'auto'
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: serpent7776 at gmail dot com
  Target Milestone: ---

Sorry for the title, but I don't know how to describe the issue.

The following code fails to compile with error message:

<source>: In instantiation of 'int fun(Ts ...) [with Ts = {int, int, int}]':
<source>:26:10:   required from here
<source>:21:41: error: invalid use of 'auto'
   21 |     return pack.template Value<0, int>::value;
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
Compiler returned: 1


The mentioned line doesn't have `auto`, so it's at best a misleading error
message. `auto` from error message refers to the `auto` on previous line.
Clang compiles the code without issue.

If I remove `template` keyword from offending line, gcc compiles the code
without issue.

gcc 11.2 x86_64
flags: -std=c++17 -Wall -Wextra -pedantic -O2


#include <utility>

template <std::size_t, typename T>
struct Value
{
        const T& value;
};

template <class Idxs, class ...Ts>
struct Pack;

template <std::size_t ...Idxs, typename ...Ts>
struct Pack<std::index_sequence<Idxs...>, Ts...> : Value<Idxs, Ts>...
{
};

template <typename ...Ts>
int fun(Ts... ts)
{
    auto pack = Pack<std::index_sequence_for<Ts...>, Ts...> {{ts}...};
    return pack.template Value<0, int>::value;
}

void f()
{
    fun<>(1, 2, 3);
}


link to godbolt to see the issue:
https://godbolt.org/z/z7so93Wq8

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

* [Bug c++/101792] Compiling access to templated parent object fails with unrelated message: invalid use of 'auto'
  2021-08-05 19:04 [Bug c++/101792] New: Compiling access to templated parent object fails with unrelated message: invalid use of 'auto' serpent7776 at gmail dot com
@ 2021-08-05 20:22 ` redi at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-05 20:22 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
           Keywords|                            |rejects-valid
   Last reconfirmed|                            |2021-08-05

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

end of thread, other threads:[~2021-08-05 20:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-05 19:04 [Bug c++/101792] New: Compiling access to templated parent object fails with unrelated message: invalid use of 'auto' serpent7776 at gmail dot com
2021-08-05 20:22 ` [Bug c++/101792] " 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).