nkzxw / ontl

Automatically exported from code.google.com/p/ontl
0 stars 0 forks source link

warning during compilation std::basic_string::operator[] #27

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1>d:\dev\ontl.svn\branches\x64\ntl\stlx\string.hxx(408) : warning C4172: 
returning address of local variable or temporary
1>        d:\dev\ontl.svn\branches\x64\ntl\stlx\string.hxx(406) : while 
compiling class template member function 'const wchar_t 
&std::basic_string<charT>::operator [](unsigned int) const'

the related code is:
const_reference operator[](size_type pos) const
    {
      static const charT zero_char = charT();
      return pos < str.size() ? *(begin() + pos) : zero_char;
    }

I recommend you to remove const keyword from static variable to avoid this 
warning:

const_reference operator[](size_type pos) const
    {
      static charT zero_char = charT();
      return pos < str.size() ? *(begin() + pos) : zero_char;
    }

Original issue reported on code.google.com by andy.ya...@gmail.com on 9 Mar 2009 at 4:52

GoogleCodeExporter commented 9 years ago
Fixed in r514.

Original comment by icestudent@gmail.com on 9 Mar 2009 at 6:27