view gcc/testsuite/gcc.dg/analyzer/data-model-15.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
line wrap: on
line source

#include <string.h>

struct coord
{
  double x;
  double y;
  double z;
};

struct tri {
  struct coord verts[3];
};

double test_1 (void)
{
  struct tri t;
  memset (&t, 0, sizeof (struct tri));
  return t.verts[1].y;
}

int test_2 (const struct coord *c1, const struct coord *c2, double r_squared)
{
  double dx = c1->x - c2->x;
  double dy = c1->y - c2->y;
  double dz = c1->z - c2->z;
  return (dx * dx) + (dy * dy) + (dz * dz) <= r_squared;
}

int test_3 (const struct coord *c1, const struct coord *c2, struct coord *out)
{
  out->x = c1->x + c2->x;
  out->y = c1->y + c2->y;
  out->z = c1->z + c2->z;
}