Fluorohydride / ygopro

A script engine for "yu-gi-oh!" and sample gui
GNU General Public License v2.0
1.85k stars 596 forks source link

remove unnecessary pointer cast #2525

Closed salix5 closed 7 months ago

salix5 commented 7 months ago

@mercury233 struct sqlite3_vfs_t user-defined type

https://github.com/Fluorohydride/ygopro/blob/4c0ca0f1b9b8c9b0389ca43f67bc8070801509fd/gframe/spmemvfs/spmemvfs.c#L259 There is only 1 sqlite3_vfs_t object, g_spmemvfs, so there is only 1 sqlite3_vfs object, g_spmemvfs.base.

The pointer cast breaks strict aliasing rule, and it is unnecessary.

DailyShana commented 7 months ago

A pointer to a struct can be cast to a pointer to its first member and vice versa. This do not violate strict aliasing rule https://stackoverflow.com/questions/50383187/is-it-a-strict-aliasing-violation-to-alias-a-struct-as-its-first-member https://stackoverflow.com/questions/60536422/pointer-aliasing-between-struct-and-first-member-of-struct