icE1usb fw: Workaround some apparent GCC aliasing bug ...

If the code is built either :
 * without -flto
 * with -fno-strict-aliasing
 * with that struct as 'static' (so it's not on the stack)

Then all works fine. But in the current situation (without the
patch), GCC seems to think there is some aliasing and just plain
removed the `notif.bits = 1` bit of code in that functions
(no warnings printed ...).

Putting the struct as 'static' is the least awful workaround.

I didn't bother reporting bug upstream, because I can't reproduce
on a small test case and I'm sure I'd just get yelled at and that
the compiler is right for some reason ...

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ie0a2ce337ce4a9c08c3d27acc4d922a3e5892840
This commit is contained in:
Sylvain Munaut 2024-03-06 11:20:40 +01:00
parent 71a9bcfd64
commit a53f23ad30
1 changed files with 2 additions and 1 deletions

View File

@ -143,7 +143,8 @@ usb_gps_poll(void)
if ((ep_regs->bd[0].csr & USB_BD_STATE_MSK) != USB_BD_STATE_RDY_DATA)
{
/* Default request */
struct usb_cdc_notif_serial_state notif = {
/* Put as static to work around gcc aliasing bug ... */
static struct usb_cdc_notif_serial_state notif = {
.hdr = {
.bmRequestType = USB_REQ_READ | USB_REQ_TYPE_CLASS | USB_REQ_RCPT_INTF,
.bRequest = USB_NOTIF_CDC_SERIAL_STATE,