[Bug c++/95020] New: requires expression always evaluates to true in the definition of template lambda defined within template function

okannen at gmail dot com gcc-bugzilla@gcc.gnu.org
Sat May 9 12:36:23 GMT 2020


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

            Bug ID: 95020
           Summary: requires expression always evaluates to true in the
                    definition of template lambda defined within template
                    function
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: okannen at gmail dot com
  Target Milestone: ---

gcc -v:
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/olivier/usr/libexec/gcc/x86_64-pc-linux-gnu/10/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --enable-libsanitizer
--prefix=/home/olivier/usr/ --with-gcc-major-version-only --disable-bootstrap
--enable-language=c,c++,lto
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.1.1 20200508 (GCC) 

Requires expression that appears in the definition of template lambda defined
in the body of template function always evaluates to true:

The 2 last static assertion should fire because we multiply a pointer:

void good1(){
        auto t = [](auto v)
                {
                static_assert (!requires {v*10;});
                //return v*10;
                };
        void * ptr=nullptr;
        t(ptr);
        }

template <class T>
void good2(){
        auto t = [](T v)
                {
                static_assert (!requires {v*10;});
                };
        void * ptr=nullptr;
        t(ptr);
        }

template <class T>
void bad1 (){
        auto t = [](auto v)
                {
                static_assert (requires {v*10;});
                };
        void * ptr=nullptr;
        t(ptr);
        }

template <class T>
void bad2 (){
        auto t = [](auto v)
                {
                static_assert (requires {v*10;});
                };
        T * ptr=nullptr;
        t(ptr);
        }

int main()
{
good1 ();
good2 <void*> ();
bad1 <void*> ();
bad2 <void*> ();
return 0;
}


More information about the Gcc-bugs mailing list