Date: Mon, 25 Aug 2025 20:03:33 +0000
> What about bitcast instead?
I'm thinking about the following, and don't see how bitcast is useful:
void daxpy(std::size_t n, const std::float64_t alpha, const std::float64_t* x,
std::float64_t* y) {
for (std::size_t i = 0; i < n; ++i) y[i] += alpha * x[i];
}
int main() {
std::size_t n = 40;
double alpha = 2.0;
std::vector<double> x(n, 1.0);
std::vector<double> y(n, 3.0);
daxpy(n, alpha, x.data(), y.data());
std::cout << y[17] << '\n'; // UB
}
Received on 2025-08-25 20:03:38