[Bug tree-optimization/79517] using a deque supresses compiler warning for undefined behavior

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Dec 25 03:20:11 GMT 2021


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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, though with a reduced testcase, I got the opposite effect of having
the constructor/deconstructor causing the warning to show up while not having
it causes it not to show.


struct g
{
  g();
  ~g();
};

[[gnu::always_inline]]
inline void nowarning_data(float *data, int &n)
{
  for(int i=0; i<4800; ++i)
    data[i] = n++;
}

[[gnu::always_inline]]
inline void warning_data(float *data, int &n)
{
  for(int i=0; i<4800; ++i)
    data[i] = n++;
}



void nowarning()
{
  float data[4800];
  int n { 0 };

  for(int i=0; i<800000; ++i) {
    nowarning_data(data, n);
  }
}
void warning()
{
  struct g d;
  float data[4800];
  int n { 0 };

  for(int i=0; i<800000; ++i) {
    warning_data(data, n);
  }
}


More information about the Gcc-bugs mailing list