Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type-punned pointers #16

Open
rofl0r opened this issue Feb 17, 2019 · 1 comment
Open

type-punned pointers #16

rofl0r opened this issue Feb 17, 2019 · 1 comment

Comments

@rofl0r
Copy link
Contributor

rofl0r commented Feb 17, 2019

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...

@kometbomb
Copy link
Owner

kometbomb commented Feb 17, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants