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

            Bug ID: 85310
           Summary: optimization ignoring strlen() results
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kees at outflux dot net
  Target Milestone: ---

Created attachment 43889
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43889&action=edit
test case

Something is gcc 8 is broken when dealing with strlen() results.


The correct behavior is seen in earlier versions of the compiler:

$ gcc --version
gcc (Ubuntu 7.3.0-14ubuntu1) 7.3.0
...
$ gcc -Wall -O2 -o testcase testcase.c
$ ./testcase 
MY_SIZE: 16
dst: 15
done...


The bad version happens in the current gcc trunk:


$ /home/kees/bin/gcc-snapshot/gcc --version
gcc (Ubuntu 20180322-1ubuntu1) 8.0.1 20180322 (experimental) [trunk revision
258755]
...
$ /home/kees/bin/gcc-snapshot/gcc -Wall -O2 -o testcase testcase.c
$ ./testcase 
MY_SIZE: 16
dst: 32
done...
Segmentation fault (core dumped)


Checking with godbolt confirms there is no test against "16" in the output:

https://godbolt.org/g/63Sbir

Reply via email to