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

            Bug ID: 105950
           Summary: >  O2 optimization causes runtime (SIGILL) during main
                    initialization
           Product: gcc
           Version: 9.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jkanapes at yahoo dot com
  Target Milestone: ---

Created attachment 53128
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53128&action=edit
gcc -v -save -temps

Recently upgraded to Ubuntu 20.04, and a program that compiled & ran fine in
Ubuntu 14.04, now coredumps in execution when optimization greater than -O2 is
used during compilation. No warnings in compilation.
When compiled with -O3 -g flags I get gdb output to the offending code
(SIGILL):
size_t channel = 0;
uhd_stream_args_t stream_args =
                      {
                         .cpu_format = "fc32",
                         .otw_format = "sc16",
                         .args = "",
                         .channel_list = &channel,
                         .n_channels = 1
                      };
uhd_stream_atgs_t is defined in the included header:
typedef struct {
    //! Format of host memory
    char* cpu_format;
    //! Over-the-wire format
    char* otw_format;
    //! Other stream args
    char* args;
    //! Array that lists channels
    size_t* channel_list;
    //! Number of channels
    int n_channels;
} uhd_stream_args_t;

The offending code is the next block. This initialization code used to work
fine. It bow works fine with -O2 or less optimization. It compiles fine. Why
does gcc create the wrong executable?

Attaching the gcc -v -save-temps output

Reply via email to