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

            Bug ID: 84062
           Summary: error: no matching function for call to
                    'std::vector<option_s>::push_back(<brace-enclosed
                    initializer list>)
           Product: gcc
           Version: 5.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: daffra.claudio at gmail dot com
  Target Milestone: ---

Created attachment 43251
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43251&action=edit
source code where error7bug  is generated

as you see in example below, g++ -std=c++11 fails compiler code,
when i assign a default value to a parameter in a struct definition
( i've tested with visual studio 2017 and all works good)
issue has generated in standard vectoru push back member
because it can not recognize struct correclty

g++ -v

        Using built-in specs.
        COLLECT_GCC=g++
       
COLLECT_LTO_WRAPPER=C:/TDM-GCC-64/bin/../libexec/gcc/x86_64-w64-mingw32/5.1.0/lto-wrapper.exe
        Target: x86_64-w64-mingw32
        Configured with: ../../../src/gcc-5.1.0/configure
--build=x86_64-w64-mingw32 --enable-targets=all
--enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-libgomp
--enable-lto --enable-graphite --enable-cxx-flags=-DWINPTHREAD_STATIC
--disable-build-with-cxx --disable-build-poststage1-with-cxx
--enable-libstdcxx-debug --enable-threads=posix
--enable-version-specific-runtime-libs --enable-fully-dynamic-string
--enable-libstdcxx-threads --enable-libstdcxx-time --with-gnu-ld
--disable-werror --disable-nls --disable-win32-registry --prefix=/mingw64tdm
--with-local-prefix=/mingw64tdm --with-pkgversion=tdm64-1
--with-bugurl=http://tdm-gcc.tdragon.net/bugs
        Thread model: posix
        gcc version 5.1.0 (tdm64-1) 

source code 

        #include <string>
        #include <iostream>
        #include <stdint.h>
        #include <vector>


        typedef struct option_s
        {
                        int8_t          parameter  ;   // <-- Works !
                        // int8_t               parameter = 1 ;         <--
ERROR : if i put default parameter, gcc gives me error in : vOption.push_back (
{ 1 }  ) ;          
        } option_t ;


        class Option
        {
        public:
                        std::vector<option_t>   vOption ;


                        Option(void) 
                        { 
                        } ;

                        void add  ( void )
                        {

                                vOption.push_back ( { 1 }  ) ;
                        }


        } zzz ;


        int main ( void )
        {
        return 0 ;
        }


Error Message

        prova.cpp: In member function 'void Option::add()':
        prova.cpp:29:32: error: no matching function for call to
'std::vector<option_s>::push_back(<brace-enclosed initializer list>)'
                 vOption.push_back ( { 1 }  ) ;
                                                                        ^
        In file included from
C:/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/vector:64:0,
                                         from prova.cpp:5:
       
C:/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/bits/stl_vector.h:913:7:
note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&)
[with _Tp = option_s; _Alloc = std::allocator<option_s>; std::vector<_Tp,
_Alloc>::value_type = option_s]
                   push_back(const value_type& __x)
                   ^
       
C:/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/bits/stl_vector.h:913:7:
note:   no known conversion for argument 1 from '<brace-enclosed initializer
list>' to 'const value_type& {aka const option_s&}'
       
C:/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/bits/stl_vector.h:931:7:
note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp,
_Alloc>::value_type&&) [with _Tp = option_s; _Alloc = std::allocator<option_s>;
std::vector<_Tp, _Alloc>::value_type = option_s]
                   push_back(value_type&& __x)
                   ^
       
C:/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/bits/stl_vector.h:931:7:
note:   no known conversion for argument 1 from '<brace-enclosed initializer
list>' to 'std::vector<option_s>::value_type&& {aka option_s&&}'

Reply via email to