[Bug c++/44157] New: GCC wrongly takes a std::initializer_list argument as non-deduced context

schaub-johannes at web dot de gcc-bugzilla@gcc.gnu.org
Sun May 16 12:48:00 GMT 2010


This is well-formed, but GCC does not like it

#include <initializer_list>

template<typename T>
void f(T) { }

int main() {
  std::initializer_list<int> a = { 0 };
  f(a);
}

main1.cpp: In function 'int main()':
main1.cpp:8:6: warning: deducing 'T' as 'std::initializer_list<int>'
main1.cpp:4:6: warning:   in call to 'void f(T) [with T =
std::initializer_list<int>]'
main1.cpp:8:6: warning:   (you can disable this with -fno-deduce-init-list)

The FCD says that if the argument is "an initializer list" and the parameter is
a "T", the parameter is a non-deduced context (14.8.2.1/1). In this code,
however, the argument is not an initializer list (if called as "f({0})", it
would be). Consequently, the warning is wrong.


-- 
           Summary: GCC wrongly takes a std::initializer_list argument as
                    non-deduced context
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: schaub-johannes at web dot de
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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



More information about the Gcc-bugs mailing list