Skip to content

Commit

Permalink
Silence -Wdangling-pointer warnings from gcc >= 12:
Browse files Browse the repository at this point in the history
Those local vars do _not_ actually go out of scope.

../h2shared/d_sprite.c: In function 'D_DrawSprite':
../h2shared/d_sprite.c:706:22: warning: storing the address of local variable 'spans' in 'sprite_spans' [-Wdangling-pointer=]
  706 |         sprite_spans = spans;
      |         ~~~~~~~~~~~~~^~~~~~~
../h2shared/d_sprite.c:704:25: note: 'spans' declared here
  704 |         sspan_t         spans[MAXHEIGHT+1];
      |                         ^~~~~
../h2shared/d_sprite.c:29:18: note: 'sprite_spans' declared here
   29 | static sspan_t  *sprite_spans;
      |                  ^~~~~~~~~~~~

../h2shared/r_draw.c: In function 'R_RenderBmodelFace':
../h2shared/r_draw.c:609:17: warning: storing the address of local variable 'tedge' in 'r_pedge' [-Wdangling-pointer=]
  609 |         r_pedge = &tedge;
      |         ~~~~~~~~^~~~~~~~
../h2shared/r_draw.c:589:25: note: 'tedge' declared here
  589 |         medge_t         tedge;
      |                         ^~~~~
../h2shared/r_draw.c:48:18: note: 'r_pedge' declared here
   48 | medge_t         *r_pedge;
      |                  ^~~~~~~

r_main.c: In function 'R_DrawViewModel':
r_main.c:843:34: warning: storing the address of local variable 'lightvec' in 'r_viewlighting.plightvec' [-Wdangling-pointer=]
  843 |         r_viewlighting.plightvec = lightvec;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
r_main.c:779:25: note: 'lightvec' declared here
  779 |         float           lightvec[3] = {-1, 0, 0};
      |                         ^~~~~~~~
r_main.c:28:17: note: 'r_viewlighting' declared here
   28 | static alight_t r_viewlighting = {128, 192, viewlightvec};
      |                 ^~~~~~~~~~~~~~
  • Loading branch information
sezero committed May 8, 2024
1 parent 9714ae5 commit 2085614
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions engine/h2shared/d_sprite.c
Original file line number Diff line number Diff line change
Expand Up @@ -766,4 +766,6 @@ void D_DrawSprite (void)
D_SpriteDrawSpansT2 (sprite_spans);
else
D_SpriteDrawSpans (sprite_spans);

sprite_spans = NULL; /* silence -Wdangling-pointer warnings */
}
2 changes: 2 additions & 0 deletions engine/h2shared/r_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ void R_RenderFace (msurface_t *fa, int clipflags)
}

// if no edges made it out, return without posting the surface
r_pedge = NULL; /* silence -Wdangling-pointer warnings */
if (!r_emitted)
return;

Expand Down Expand Up @@ -658,6 +659,7 @@ void R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
}

// if no edges made it out, return without posting the surface
r_pedge = NULL; /* silence -Wdangling-pointer warnings */
if (!r_emitted)
return;

Expand Down
2 changes: 2 additions & 0 deletions engine/hexen2/r_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,8 @@ static void R_DrawViewModel (void)

if (r_fov_greater_than_90)
SCR_CalcFOV(scr_fov.value);

r_viewlighting.plightvec = NULL; /* silence -Wdangling-pointer warnings */
}


Expand Down
7 changes: 7 additions & 0 deletions engine/hexenworld/client/r_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,8 @@ static void R_DrawViewModel (void)

if (r_fov_greater_than_90)
SCR_CalcFOV(scr_fov.value);

r_viewlighting.plightvec = NULL; /* silence -Wdangling-pointer warnings */
}


Expand Down Expand Up @@ -1268,6 +1270,11 @@ static void R_EdgeDrawing (qboolean Translucent)
}


/*
=============
R_DrawName
=============
*/
void R_DrawName (vec3_t origin, const char *name, int siegestatus)
{
vec3_t local, transformed;
Expand Down

0 comments on commit 2085614

Please sign in to comment.