View Issue Details

IDProjectCategoryView StatusLast Update
0002617FSSCPmath-relatedpublic2012-05-01 12:25
ReporterEchelon9 Assigned ToEchelon9  
PriorityhighSeverityblockReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.6.14 RC5 
Target Version3.6.14 
Summary0002617: LLVM warning: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to dereference it?
Descriptionwarning: argument to 'sizeof' in 'memset' call is
    the same expression as the destination; did you mean to dereference it?
    [-Wsizeof-pointer-memaccess]
    memset (this, 0, sizeof (this));
Additional InformationThe problem is this is a Pointer type, which is 4 bytes (on 32bit systems), and ints are 4 bytes (on 32bit systems).

Another case of why using memset() as a constructor in C++ is rarely correct, and often very dangerous. If mc_info was a non-POD type -- i.e. it included a std::string for example -- the memset will destroy the vtable and break the instance by setting the vtable pointer to NULL. Which is bad.

Another problem is that if the type T requires some constructor action more complex than just settings its bits to 0, then the constructors for the members are not called, but their effect is ruined by overwriting the content of the members with memset().
TagsNo tags attached.

Activities

Echelon9

2012-02-29 14:09

developer   ~0013369

Fix committed to trunk@8539.

niffiwan

2012-05-01 12:25

developer   ~0013495

Fix committed to fs2_open_3_6_14@8703.

Related Changesets

fs2open: trunk r8539

2012-02-29 09:09

Echelon9


Ported: N/A

Details Diff
Fix Mantis 2617: LLVM warning: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to dereference it? Affected Issues
0002617
mod - /trunk/fs2_open/code/model/model.h Diff File

fs2open: fs2_open_3_6_14 r8703

2012-05-01 08:26

niffiwan


Ported: N/A

Details Diff
Backport: Trunk r8539; Fix Mantis 2617: LLVM warning: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to dereference it? Affected Issues
0002617
mod - /branches/fs2_open_3_6_14/code/model/model.h Diff File

Issue History

Date Modified Username Field Change
2012-02-29 14:08 Echelon9 New Issue
2012-02-29 14:08 Echelon9 Status new => assigned
2012-02-29 14:08 Echelon9 Assigned To => Echelon9
2012-02-29 14:09 Echelon9 Changeset attached => fs2open trunk r8539
2012-02-29 14:09 Echelon9 Note Added: 0013369
2012-02-29 14:09 Echelon9 Status assigned => resolved
2012-02-29 14:09 Echelon9 Resolution open => fixed
2012-05-01 12:25 niffiwan Changeset attached => fs2open fs2_open_3_6_14 r8703
2012-05-01 12:25 niffiwan Note Added: 0013495