view gcc/testsuite/g++.dg/torture/pr78224.C @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 04ced10e8804
children
line wrap: on
line source

// { dg-do compile }

extern "C"{
  float sqrtf(float);
}

inline float squareroot(const float f)
{
  return sqrtf(f);
}

inline int squareroot(const int f)
{
  return static_cast<int>(sqrtf(static_cast<float>(f)));
}

template <class T>
class vector2d
{
public:
  vector2d(T nx, T ny) : X(nx), Y(ny) {}
  T getLength() const { return squareroot( X*X + Y*Y ); }
  T X;
  T Y;
};

vector2d<int> getMousePos();

class Client
{
public:
  Client();
  ~Client();
};

void the_game(float turn_amount)
{
  Client client;
  bool first = true;

  while (1) {
      if (first) {
        first = false;
      } else {
        int dx = getMousePos().X;
        int dy = getMousePos().Y;

        turn_amount = vector2d<float>(dx, dy).getLength();
      }
  }
}