abi-compliance-checker icon indicating copy to clipboard operation
abi-compliance-checker copied to clipboard

changes in function-like macros

Open andreasstieger opened this issue 9 years ago • 2 comments

Considering the following change of an API. We have a function-like macro where a trailing semicolon was removed:

http://svn.apache.org/viewvc/serf/trunk/serf_bucket_types.h?r1=1719435&r2=1719434&pathrev=1719435&view=patch

--- serf/trunk/serf_bucket_types.h  2015/12/11 14:41:41 1719434
+++ serf/trunk/serf_bucket_types.h  2015/12/11 14:44:59 1719435
@@ -392,10 +392,10 @@
     serf_bucket_alloc_t *allocator);

 #define SERF_BUCKET_SIMPLE_STRING(s,a) \
-    serf_bucket_simple_create(s, strlen(s), NULL, NULL, a);
+    serf_bucket_simple_create(s, strlen(s), NULL, NULL, a)

 #define SERF_BUCKET_SIMPLE_STRING_LEN(s,l,a) \
-    serf_bucket_simple_create(s, l, NULL, NULL, a);
+    serf_bucket_simple_create(s, l, NULL, NULL, a)

 /* ==================================================================== */

The old version could be used as a "function call" without semicolon, with semicolon (in which case it would expand to a double semicolon), but not as a function argument.

The new version can be used as a function argument, but must also carry a semicolon when called like a function as a single statement. The dev team has noted that this change is not 100% backwards compatible. In fact some calling code itself needed to change: http://svn.apache.org/viewvc?view=revision&revision=1719435 http://svn.apache.org/viewvc/serf/trunk/test/test_buckets.c?r1=1719435&r2=1719434&pathrev=1719435

A check could be added for all function-like macros as to whether there is a change w.r.t. using them as a function macro, or requiring a trailing semicolon when calling the macro. This could be addressed by trial compilation.

andreasstieger avatar Dec 18 '15 09:12 andreasstieger

Hello,

Thank you for reporting issues.

Such changes in function-like macro are filtered out from the "Binary compatibility" tab of the report by the constantFilter() subroutine.

Is this change listed in the "Source compatibility" tab of the report?

aponomarenko avatar Jan 28 '16 13:01 aponomarenko

This is a minor source compatibility issue, but it is not show in the source incompatibility tab.

#!/bin/sh
svn co -r1719435 https://svn.apache.org/repos/asf/serf/trunk serf-r1719435
svn co -r1719434 https://svn.apache.org/repos/asf/serf/trunk serf-r1719434
pushd serf-r1719435
scons
popd
pushd serf-r1719434
scons
popd
abi-compliance-checker -o serf-r1719434 -v1 r1719434 -n serf-r1719435 -v2 r1719435 -l libserf

The report returns 100% source compatibility, and I made sure the header containing this change was picked up.

Using GCC 4.8 (x86_64-suse-linux, target: x86_64) WARNING: Not working properly with GCC 4.8. Please update or downgrade GCC or use a local installation by --gcc-path=PATH option. checking header(s) r1719434 ... Using C++ compatibility mode checking header(s) r1719435 ... Using C++ compatibility mode comparing ABIs ... comparing APIs ... creating compatibility report ... result: COMPATIBLE total "Binary" compatibility problems: 0, warnings: 0 total "Source" compatibility problems: 0, warnings: 0 see detailed report: compat_reports/libserf/r1719434_to_r1719435/compat_report.html

andreasstieger avatar Jan 28 '16 13:01 andreasstieger