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

            Bug ID: 110530
           Summary: Local variable unexpectedly assigned to zero during
                    passing as an argument
           Product: gcc
           Version: 11.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: haiqingzhao at microsoft dot com
  Target Milestone: ---

Created attachment 55462
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55462&action=edit
This source file reproduces the issue occurring under -Os optimization

1) GCC version: 11.3.0
2) System type: ubuntu 22.04.1
3) Option given: -Os
4) The complete command line that triggers the bug:
    i.  gcc -Os test.c -o test.o
    ii. ./test.o
5) No compiler output error messages or warning messages
6) No pre-processed files
7) Description:
    The behaviour of the source file (test.c) works normally under gcc version
9.4.0 no matter if "-Os optimization" is enabled or not. It works still
normally under gcc version 11.3.0 with no optimization enabled, but prints
error message when "-Os optimization" is enabled.
    During debugging, it is found that the value of the local variable "size"
is unexpectedly assigned to zero inside the function "process_data" before
calling the function "get_data" at line 18.
    It looks like the initialization for the local variable "size" at line 27
is executed after calling the function "get_data" at line 29.
8) Experiment has been done:
    i. The source code works normally if the type for the local variable "size"
is changed from unsigned int to unsigned long

Reply via email to