lvc / abi-compliance-checker

A tool for checking backward API/ABI compatibility of a C/C++ library
https://lvc.github.io/abi-compliance-checker/
GNU Lesser General Public License v2.1
621 stars 76 forks source link

Enum member changed but not deteced #90

Open jczhang07 opened 5 years ago

jczhang07 commented 5 years ago

./abi-compliance-checker/abi-compliance-checker.pl -lib libpetsc -dump old.xml -dump-path old.abi ./abi-compliance-checker/abi-compliance-checker.pl -lib libpetsc -dump new.xml -dump-path new.abi ./abi-compliance-checker/abi-compliance-checker.pl -l libpetsc -old old.xml -new new.xml

The new library changed the name of an enum member (but the value is the same). But the tool could not detect this API change.

jczhang07 commented 5 years ago

I could not reproduce the problem with the builtin test, ./abi-compliance-checker.pl -test. If you want the ABI dumps to debug, I can send you.

jczhang07 commented 5 years ago

I reduced the problem to an enum as following.

//V1 libsample.h
enum EnumMemberRenamed {MEMBER1,MEMBER2};
int enumMemberRenamed(enum EnumMemberRenamed param);
//V1 libsample.c
#include "libsample.h"
int enumMemberRenamed(enum EnumMemberRenamed param) {return 0;}
//V2 libsample.h
enum EnumMemberRenamed {MEMBER1,MEMBER2_RENAMED};
int enumMemberRenamed(enum EnumMemberRenamed param);
//V2 libsample.c
#include "libsample.h"
int enumMemberRenamed(enum EnumMemberRenamed param) {return 0;}

./abi-compliance-checker.pl -l libsample -old v1.xml -new v2.xml -source ... Source compatibility: 0% Total source compatibility problems: 1, warnings: 0

However, if I changed prototype the function in .h and .c in both versions as below int enumMemberRenamed(int param); ./abi-compliance-checker.pl -l libsample -old v1.xml -new v2.xml -source ... Source compatibility: 100% Total source compatibility problems: 0, warnings: 0

Thank you!