kometbomb/klystron

type-punned pointers

Opened this issue · 1 comments

src/gfx/objhdr.c: In function 'objhdr_draw':
src/gfx/objhdr.c:230:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
    gfx_rect(destination, &dest, *(Uint32*)&object->surface);
    ^~~~~~~~
src/gui/filebox.c: In function 'pick_file_action':
src/gui/filebox.c:385:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  if (data.focus == FOCUS_LIST && data.selected_file == CASTPTR(int,file)) data.picked_file = &data.files[CASTPTR(int,file)];
  ^~
src/gui/filebox.c:385:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
src/gui/filebox.c:386:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  data.selected_file = CASTPTR(int,file);
src/gui/dialog.c: In function 'flip':
src/gui/dialog.c:37:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  *CASTTOPTR(Uint32,bits) ^= CASTPTR(Uint32,mask);
  ^
src/gui/menu.c: In function 'close_menu':
src/gui/menu.c:87:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
    if (current_menu_action->action == MENU_CHECK) *(int*)(current_menu_action->p1) ^= CASTPTR(int,current_menu_action->p2);
    ^~
src/gui/menu.c: In function 'draw_submenu':
src/gui/menu.c:271:6: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
      if ((item->action == MENU_CHECK || item->action == MENU_CHECK_NOSET) && (*(int*)item->p1 & CASTPTR(int,item->p2)))
      ^~
src/gui/view.c: In function 'draw_view':
src/gui/view.c:84:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   area.w = *(Sint16*)&view->position.w > 0 ? *(Sint16*)&view->position.w : dest->screen_w + *(Sint16*)&view->position.w - view->position.x;
   ^~~~
src/gui/view.c:84:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
src/gui/view.c:84:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
src/gui/view.c:85:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   area.h = *(Sint16*)&view->position.h > 0 ? *(Sint16*)&view->position.h : dest->screen_h + *(Sint16*)&view->position.h - view->position.y;
   ^~~~
src/gui/view.c:85:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
src/gui/view.c:85:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
src/gui/slider.c: In function 'modify_position':
src/gui/slider.c:42:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  *param->position = quant(*param->position + CASTPTR(int,delta), param->granularity);
  ^

i guess those should be fixed as it can cause bad codegen...

Yeah I need to check if that's actually needed anymore. The original code relied on being able to pass objects to the library functions that were not exactly ObjHdr etc. but had that as the "header" of the data.