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

--- Comment #4 from Moritz Beutel <spamandnoise at gmail dot com> ---
Interesting. I had figured that the test case could probably be reduced
further, but I didn't try because the bug appeared so brittle. Slightly
changing seemingly unrelated details made it vanish:

-----
// line 10:
        if ( _size != 0 && _data == nullptr ) throw 42;  // bug
        //if ( _size != 0 && _data == nullptr ) throw 42;  // no bug

// line 23:
size_t string_length( char const * ptr, size_t max = (size_t) -1 )  // bug
size_t string_length( char const * ptr, size_t max = (size_t) -2 )  // no bug

// line 26:
    while ( len < max && ptr[len] )  // bug
    while ( ptr[len] )  // no bug

-----

Link for experimentation: https://gcc.godbolt.org/z/af8P7v64T

Reply via email to