[Bug c++/86400] [8/9 regression] set<string>::set<char (*)[2]) constructor does not work with array argument

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jul 4 22:50:00 GMT 2018


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|jwakely.gcc at gmail dot com       |msebor at gcc dot gnu.org,
                   |                            |redi at gcc dot gnu.org

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced further:

void
foo2 ()
{
  static char root[1][2] = {"/"};
  auto len = __builtin_strlen(*root);
  if (len != 1)
          __builtin_abort();
}

int
main ()
{
  foo2 ();
}


This started to fail with r255790

    PR middle-end/83373 - False positive reported by -Wstringop-overflow        
    PR tree-optimization/78450 - strlen(s) return value can be assumed to be
less than the size of s                                                         

    gcc/ChangeLog:                                                              

            PR middle-end/83373                                                 
            PR tree-optimization/78450                                          
            * tree-ssa-strlen.c (maybe_set_strlen_range): New function.         
            (handle_builtin_strlen): Call it.                                   

    gcc/testsuite/ChangeLog:                                                    

            PR middle-end/83373                                                 
            PR tree-optimization/78450                                          
            * gcc.dg/pr83373.c: New test.                                       
            * gcc.dg/strlenopt-36.c: New test.                                  
            * gcc.dg/strlenopt-37.c: New test.


More information about the Gcc-bugs mailing list