public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107858] New: Variable in generic lambda incorrectly considered to be a dependent name
@ 2022-11-24 12:44 pilarlatiesa at gmail dot com
  2022-11-24 15:13 ` [Bug c++/107858] structed binding with auto type and for all loop in a template considered a type " pinskia at gcc dot gnu.org
  2022-11-24 15:14 ` [Bug c++/107858] structured " pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: pilarlatiesa at gmail dot com @ 2022-11-24 12:44 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107858
           Summary: Variable in generic lambda incorrectly considered to
                    be a dependent name
           Product: gcc
           Version: 11.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pilarlatiesa at gmail dot com
  Target Milestone: ---

$ cat test.cpp

struct T
{
  template<int>
  void foo() const {}
};

template<typename T>
struct pair
{
  T a, b;
};

void bar()
{
  [](auto)
  {
    pair<T> x[10];
    for (auto const &[a, b] : x) a.foo<0>();
  };
}

$ g++-11 -c test.cpp 
test.cpp: In lambda function:
test.cpp:19:43: error: expected primary-expression before ‘)’ token
   19 |     for (auto const &[a, b] : x) a.foo<0>();
      |                                           ^

$ g++-11 -v
Using built-in specs.
COLLECT_GCC=g++-11
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
11.1.0-1ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-11
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib
--enable-libphobos-checking=release --with-target-system-zlib=auto
--enable-objc-gc=auto --enable-multiarch --disable-werror --disable-cet
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-11-2V7zgg/gcc-11-11.1.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-2V7zgg/gcc-11-11.1.0/debian/tmp-gcn/usr
--without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
--with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.1.0 (Ubuntu 11.1.0-1ubuntu1~20.04)


It can be worked around by typing a.template foo<0>(), which shouldn’t be
necessary.

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

* [Bug c++/107858] structed binding with auto type and for all loop in a template considered a type dependent name
  2022-11-24 12:44 [Bug c++/107858] New: Variable in generic lambda incorrectly considered to be a dependent name pilarlatiesa at gmail dot com
@ 2022-11-24 15:13 ` pinskia at gcc dot gnu.org
  2022-11-24 15:14 ` [Bug c++/107858] structured " pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-24 15:13 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
            Summary|Variable in generic lambda  |structed binding with auto
                   |incorrectly considered to   |type and for all loop in a
                   |be a dependent name         |template considered a type
                   |                            |dependent name
   Last reconfirmed|                            |2022-11-24

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is unrelated to generic lambdas and can reproduce with just a templated
function:
```
struct y
{
  template<int>
  void foo() const {}
};

template<typename T>
struct pair
{
  T a, b;
};

template<class t>
void bar(void)
{
    pair<y> x[10];
    for (auto const &[a, b] : x)
      a.foo<0>();
}
```

Note the forall loop is required.
I wonder if that is because begin and end are considered type depdent ...
But not using structured binding, GCC does not considered them as type depdent.
Confirmed.

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

* [Bug c++/107858] structured binding with auto type and for all loop in a template considered a type dependent name
  2022-11-24 12:44 [Bug c++/107858] New: Variable in generic lambda incorrectly considered to be a dependent name pilarlatiesa at gmail dot com
  2022-11-24 15:13 ` [Bug c++/107858] structed binding with auto type and for all loop in a template considered a type " pinskia at gcc dot gnu.org
@ 2022-11-24 15:14 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-24 15:14 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 84469.

*** This bug has been marked as a duplicate of bug 84469 ***

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

end of thread, other threads:[~2022-11-24 15:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-24 12:44 [Bug c++/107858] New: Variable in generic lambda incorrectly considered to be a dependent name pilarlatiesa at gmail dot com
2022-11-24 15:13 ` [Bug c++/107858] structed binding with auto type and for all loop in a template considered a type " pinskia at gcc dot gnu.org
2022-11-24 15:14 ` [Bug c++/107858] structured " pinskia 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).