<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62009>62009</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang 16.0.x generate wrong code with -O1 or -O2
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
scu319hy
</td>
</tr>
</table>
<pre>
```c++
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
struct rect_t {
int32_t left;
int32_t top;
int32_t right;
int32_t bottom;
inline void resize(int32_t cx, int32_t cy) {
this->right = this->left + cx;
this->bottom = this->top + cy;
}
inline void move(int32_t x, int32_t y) {
right = width() + x;
bottom = height() + y;
left = x;
top = y;
}
inline int32_t width() const {
return right - left;
}
inline int32_t height() const {
return bottom - top;
}
};
void _prepare_frame_buttons(rect_t &rc_close, rect_t &rc_max) {
int32_t btn_width = 28;
int32_t btn_height = 22;
int32_t frame_offset = 9;
rc_close.resize(btn_width, btn_height);
rc_max.resize(btn_width, btn_height);
rc_close.move(100 - rc_close.width() - frame_offset, frame_offset);
rc_max.move(rc_close.left - rc_max.width() - 2, frame_offset);
}
int main() {
rect_t a, b;
_prepare_frame_buttons(a, b);
printf("a: (%d, %d) - (%d, %d)\n", a.left, a.top, a.right, a.bottom);
printf("b: (%d, %d) - (%d, %d)\n", b.left, b.top, b.right, b.bottom);
return 0;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVcuOqzgQ_RqzsYiMDQksWHR3brb3EyJjHPAI7Mguujvz9SPMI5DQmasrRcHU65yqOgB3TlVayhwl7yg5BryD2tjciY5FWX0LClPecrQnw08g-t7_yBGRN0SZ0qLpSokR-3BQKrOrEfv1g7dRxSu30rB0-38HthOArRRwBowOEzDJlAZGz4AbeQHEnu1grltmq6p6M74wAKZdeGZ_o7TEn0aV2Eqn_pWIplOS-Eb0A893N0SzFUlEMqiVCxH75YExYkc8WXrmGNH3vgrbzBk4rZLAXIec2yrncHxBuzWfS9IrzluU71S_VAk1oqkPou_4keiCYC39ZO-xt4fYoV12fCriW2JH_GcdTcSX1ITRDp66kNBZPSwch086-V-AVUOvEMYhhI-SuyMcjg-68ms5X628civPF8tbeS46AKMdoumkdrq34iwa42S_sZW15d-Pi5uFDPrsh-OHStNNsYM-D_0NQXQraKBlLhcnh7BsGTVR280PxQzcs70jIPqY1_Lvv8ga0EYtR4TgEM_WpRjCFfG-6vp-i81Yda7nterr9951dfqy5FpVSgNuudLTY7FY17hO7tteUvpRFmPouoGrVRouvj7liL1hf0zKPna49pyfjSj50Ij6Xrhvdzj1EvaH4T3pj-Ob8Wfc4u9wixm3mHCLO26xjTs-c2Rj4tMnKihzVmYs44HMo31KMhan-zio84RHLIvLQ3bgKaH7kl-SMqYpKalIoojEgcopoYzEJCV7GpF4V0TphSdFKjkTgkiCYiJbrppd03y2O2OrQDnXyXxPCcmChheycf47SqmWX9g7-26TY2DzPicsusqhmDTKgbtXAQWNzEXDdYWj_Y7svnEltbQcJP6yRldYmFLiLwU1Dn9H2Fgc_qZBZ5u8Brg6xN4QPSF6qhTUXbET_dxOffnxEl6t-UcKQPTkSTlET570fwEAAP__daNG2g">