MantisBT - CMake
View Issue Details
0015203CMakeModulespublic2014-10-10 17:462015-07-08 08:57
Peter Wu 
Brad King 
normalminoralways
closedfixed 
CMake 3.0.2 
CMake 3.2CMake 3.2 
0015203: CheckStructHasMember breaks on -Wunused-value
When CMAKE_C_FLAGS containg -Wall -Werror, CheckStructHasMember will always fail due to the generated code appearing as:

int main()
{
    struct FOO* s;
    s->MEMBER;
    return 0;
}

See the attached patch for a fix. Don't know whether some -std flag will also bail out on int main() rather than int main(void), but that's a different issue. This one is about breakage due to very strict warnings on a modern compiler (GCC 4.9.1).
No tags attached.
related to 0015413closed Brad King CheckStructHasMember generates an uninitialized variable warning 
patch 0001-CheckStructHasMember-avoid-breakage-on-Wall.patch (776) 2014-10-10 17:46
https://public.kitware.com/Bug/file/5273/0001-CheckStructHasMember-avoid-breakage-on-Wall.patch
patch 0001-CheckStructHasMember-avoid-clang-Wall-breakage.patch (999) 2014-10-30 13:56
https://public.kitware.com/Bug/file/5287/0001-CheckStructHasMember-avoid-clang-Wall-breakage.patch
patch 0001-CheckStructHasMember-fix-null-deref-warning.patch (941) 2015-02-15 18:27
https://public.kitware.com/Bug/file/5385/0001-CheckStructHasMember-fix-null-deref-warning.patch
Issue History
2014-10-10 17:46Peter WuNew Issue
2014-10-10 17:46Peter WuFile Added: 0001-CheckStructHasMember-avoid-breakage-on-Wall.patch
2014-10-13 08:11Brad KingNote Added: 0037024
2014-10-14 10:04Brad KingAssigned To => Brad King
2014-10-14 10:04Brad KingStatusnew => resolved
2014-10-14 10:04Brad KingResolutionopen => fixed
2014-10-14 10:04Brad KingFixed in Version => CMake 3.1
2014-10-14 10:04Brad KingTarget Version => CMake 3.1
2014-10-30 13:56Peter WuNote Added: 0037110
2014-10-30 13:56Peter WuStatusresolved => feedback
2014-10-30 13:56Peter WuResolutionfixed => reopened
2014-10-30 13:56Peter WuFile Added: 0001-CheckStructHasMember-avoid-clang-Wall-breakage.patch
2014-10-30 13:56Peter WuNote Edited: 0037110bug_revision_view_page.php?bugnote_id=37110#r1603
2014-10-30 14:12Brad KingStatusfeedback => assigned
2014-10-30 14:12Brad KingResolutionreopened => open
2014-10-30 14:12Brad KingFixed in VersionCMake 3.1 =>
2014-10-30 14:12Brad KingTarget VersionCMake 3.1 => CMake 3.2
2014-10-30 14:17Brad KingNote Added: 0037111
2014-11-03 09:32Brad KingStatusassigned => resolved
2014-11-03 09:32Brad KingResolutionopen => fixed
2014-11-03 09:32Brad KingFixed in Version => CMake 3.2
2015-02-15 18:27Peter WuFile Added: 0001-CheckStructHasMember-fix-null-deref-warning.patch
2015-02-15 18:29Peter WuNote Added: 0037979
2015-02-15 18:29Peter WuStatusresolved => feedback
2015-02-15 18:29Peter WuResolutionfixed => reopened
2015-02-16 09:28Brad KingNote Added: 0037981
2015-02-20 10:42Brad KingNote Added: 0038006
2015-02-20 10:42Brad KingStatusfeedback => resolved
2015-02-20 10:42Brad KingResolutionreopened => fixed
2015-02-20 11:24Brad KingRelationship addedrelated to 0015413
2015-07-08 08:57Robert MaynardNote Added: 0039058
2015-07-08 08:57Robert MaynardStatusresolved => closed

Notes
(0037024)
Brad King   
2014-10-13 08:11   
Applied, thanks:

 CheckStructHasMember: avoid breakage on -Wall -Werror
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=384d3ce7 [^]
(0037110)
Peter Wu   
2014-10-30 13:56   
With -DCMAKE_C_COMPILER=clang and -Wall -Werror, clang will bail out with -Wuninitialized. Please find the new patch on top of the previous one.

(0037111)
Brad King   
2014-10-30 14:17   
Applied, thanks:

 CheckStructHasMember: Avoid clang -Wall breakage
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8d6ba358 [^]
(0037979)
Peter Wu   
2015-02-15 18:29   
Clang Static Analyzer is great, but it results in defect reports due to the current macro. Hopefully this is the final patch.

It was successfully tested against Wireshark.
(0037981)
Brad King   
2015-02-16 09:28   
Re 0015203:0037979: This patch for the first time requires the struct to be allocated (on stack). When using LANGUAGE CXX this could be a problem if the structure does not have a default constructor or needs to link to symbols.

We need a solution that still goes through a pointer dereference so that no other requirements are checked.
(0038006)
Brad King   
2015-02-20 10:42   
The problem originally reported here has been addressed in CMake 3.2. The issue raised in 0015203:0037979 is separate and will have to be addressed in post-3.2 development. Please open a separate issue for that or just read CONTRIBUTING.rst and bring a patch to the mailing list.
(0039058)
Robert Maynard   
2015-07-08 08:57   
Closing resolved issues that have not been updated in more than 4 months.