http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59655

            Bug ID: 59655
           Summary: incorrect diagnostic on templatized function with
                    lambda parameter
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pab at pabigot dot com

Created attachment 31555
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31555&action=edit
Reproducing code

The attached program uses tricks to produce a user-level diagnostic for
function misuse through a static_assert without also producing diagnostics
about the constraint that the static_assert checks.  While this works correctly
for normal types, an extra and incorrect diagnostic is produced when a lambda
type is involved.  Specifically, -fpermissive complains that a function is used
but never defined, while pointing at the function's definition.

llc[1082]$  g++ --version
g++ (GCC) 4.9.0 20131210 (experimental)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

llc[1083]$ g++ -DWITH_LAMBDA=0  -Wall -std=c++11 -c sabug.cc
sabug.cc: In instantiation of ‘void useit(T1&, T2) [with T1 =
std::basic_string<char>; T2 = std::basic_string<wchar_t>]’:
sabug.cc:86:15:   required from here
sabug.cc:69:3: error: static assertion failed: cannot assign
   static_assert(template_types_ok::value, "cannot assign");
   ^
llc[1084]$ g++ -DWITH_LAMBDA=1  -Wall -std=c++11 -c sabug.cc
sabug.cc: In instantiation of ‘void useit(T1&, T2) [with T1 =
std::basic_string<char>; T2 = main()::<lambda()>]’:
sabug.cc:84:30:   required from here
sabug.cc:69:3: error: static assertion failed: cannot assign
   static_assert(template_types_ok::value, "cannot assign");
   ^
sabug.cc:53:6: error: ‘void useit_(T1&, T2, std::false_type) [with T1 =
std::basic_string<char>; T2 = main()::<lambda()>; std::false_type =
std::integral_constant<bool, false>]’, declared using local type
‘main()::<lambda()>’, is used but never defined [-fpermissive]
 void useit_ (T1& t1, T2 t2, std::false_type template_ok)
      ^
llc[1085]$

Reply via email to