google / benchmark

A microbenchmark support library
Apache License 2.0
8.69k stars 1.59k forks source link

[BUG] 1.8.0: Tests fail to compile: too many arguments provided to function-like macro invocation #1593

Closed yurivict closed 6 months ago

yurivict commented 1 year ago

Describe the bug

FAILED: test/CMakeFiles/cxx03_test.dir/cxx03_test.cc.o 
/usr/local/libexec/ccache/c++ -DHAVE_POSIX_REGEX -DHAVE_STD_REGEX -DHAVE_STEADY_CLOCK -DHAVE_THREAD_SAFETY_ATTRIBUTES -DTEST_BENCHMARK_LIBRARY_HAS_NO_ASSERTIONS -I/usr/ports/devel/benchmark/work/benchmark-1.8.0/include -O2 -pipe -fstack-protector-strong -fno-strict-aliasing  -Wall  -Wextra  -Wshadow  -Wfloat-equal  -Werror  -pedantic  -pedantic-errors  -Wshorten-64-to-32  -fstrict-aliasing  -Wno-deprecated-declarations  -Wno-deprecated  -Wstrict-aliasing  -Wthread-safety -O2 -pipe -fstack-protector-strong -fno-strict-aliasing     -std=c++98 -fvisibility=hidden -fvisibility-inlines-hidden   -UNDEBUG -w -MD -MT test/CMakeFiles/cxx03_test.dir/cxx03_test.cc.o -MF test/CMakeFiles/cxx03_test.dir/cxx03_test.cc.o.d -o test/CMakeFiles/cxx03_test.dir/cxx03_test.cc.o -c /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc:5:
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1712:
In file included from /usr/include/c++/v1/memory:842:
In file included from /usr/include/c++/v1/__algorithm/move.h:12:
/usr/include/c++/v1/__algorithm/iterator_operations.h:101:9: error: too many arguments provided to function-like macro invocation
        "It looks like your iterator's `iterator_traits<It>::reference` does not match the return type of "
        ^
/usr/include/sys/cdefs.h:284:9: note: macro '_Static_assert' defined here
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
        ^

System Which OS, compiler, and compiler version are you using:

To reproduce run tests

LebedevRI commented 1 year ago

Sounds like clang-15 + libc++15 is needed to reproduce? About which iterator is it complaining? Is that the whole error message?

yurivict commented 1 year ago

Here is a complete error message:

FAILED: test/CMakeFiles/cxx03_test.dir/cxx03_test.cc.o 
/usr/local/libexec/ccache/c++ -DHAVE_POSIX_REGEX -DHAVE_STD_REGEX -DHAVE_STEADY_CLOCK -DHAVE_THREAD_SAFETY_ATTRIBUTES -DTEST_BENCHMARK_LIBRARY_HAS_NO_ASSERTIONS -I/usr/ports/devel/benchmark/work/benchmark-1.8.0/include -O2 -pipe -fstack-protector-strong -fno-strict-aliasing  -Wall  -Wextra  -Wshadow  -Wfloat-equal  -Werror  -pedantic  -pedantic-errors  -Wshorten-64-to-32  -fstrict-aliasing  -Wno-deprecated-declarations  -Wno-deprecated  -Wstrict-aliasing  -Wthread-safety -O2 -pipe -fstack-protector-strong -fno-strict-aliasing     -std=c++98 -fvisibility=hidden -fvisibility-inlines-hidden   -UNDEBUG -w -MD -MT test/CMakeFiles/cxx03_test.dir/cxx03_test.cc.o -MF test/CMakeFiles/cxx03_test.dir/cxx03_test.cc.o.d -o test/CMakeFiles/cxx03_test.dir/cxx03_test.cc.o -c /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc:5:
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1712:
In file included from /usr/include/c++/v1/memory:842:
In file included from /usr/include/c++/v1/__algorithm/move.h:12:
/usr/include/c++/v1/__algorithm/iterator_operations.h:101:9: error: too many arguments provided to function-like macro invocation
        "It looks like your iterator's `iterator_traits<It>::reference` does not match the return type of "
        ^
/usr/include/sys/cdefs.h:284:9: note: macro '_Static_assert' defined here
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
        ^
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc:5:
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1712:
In file included from /usr/include/c++/v1/memory:842:
In file included from /usr/include/c++/v1/__algorithm/move.h:12:
/usr/include/c++/v1/__algorithm/iterator_operations.h:103:90: error: expected '('
        "and can lead to dangling reference issues at runtime, so we are flagging this.");
                                                                                         ^
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc:5:
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1719:
In file included from /usr/include/c++/v1/__algorithm/binary_search.h:14:
/usr/include/c++/v1/__algorithm/lower_bound.h:53:61: error: too many arguments provided to function-like macro invocation
  static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value,
                                                            ^
/usr/include/sys/cdefs.h:284:9: note: macro '_Static_assert' defined here
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
        ^
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc:5:
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1719:
In file included from /usr/include/c++/v1/__algorithm/binary_search.h:14:
/usr/include/c++/v1/__algorithm/lower_bound.h:54:53: error: expected '('
                "The comparator has to be callable");
                                                    ^
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc:5:
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1730:
/usr/include/c++/v1/__algorithm/equal_range.h:63:61: error: too many arguments provided to function-like macro invocation
  static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value,
                                                            ^
/usr/include/sys/cdefs.h:284:9: note: macro '_Static_assert' defined here
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
        ^
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc:5:
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1730:
/usr/include/c++/v1/__algorithm/equal_range.h:64:53: error: expected '('
                "The comparator has to be callable");
                                                    ^
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc:5:
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1734:
In file included from /usr/include/c++/v1/__algorithm/find_end.h:15:
/usr/include/c++/v1/__algorithm/search.h:177:70: error: too many arguments provided to function-like macro invocation
  static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value,
                                                                     ^
/usr/include/c++/v1/__config:685:27: note: expanded from macro 'decltype'
#    define decltype(...) __decltype(__VA_ARGS__)
                          ^
/usr/include/sys/cdefs.h:284:9: note: macro '_Static_assert' defined here
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
        ^
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc:5:
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1734:
In file included from /usr/include/c++/v1/__algorithm/find_end.h:15:
/usr/include/c++/v1/__algorithm/search.h:178:54: error: expected '('
                "BinaryPredicate has to be callable");
                                                     ^
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc:5:
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1749:
/usr/include/c++/v1/__algorithm/includes.h:48:62: error: too many arguments provided to function-like macro invocation
  static_assert(__is_callable<_Compare, decltype(*__first1), decltype(*__first2)>::value,
                                                             ^
/usr/include/c++/v1/__config:685:27: note: expanded from macro 'decltype'
#    define decltype(...) __decltype(__VA_ARGS__)
                          ^
/usr/include/sys/cdefs.h:284:9: note: macro '_Static_assert' defined here
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
        ^
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc:5:
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1749:
/usr/include/c++/v1/__algorithm/includes.h:49:39: error: expected '('
      "Comparator has to be callable");
                                      ^
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc:5:
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1750:
In file included from /usr/include/c++/v1/__algorithm/inplace_merge.h:16:
In file included from /usr/include/c++/v1/__algorithm/min.h:14:
/usr/include/c++/v1/__algorithm/min_element.h:54:61: error: too many arguments provided to function-like macro invocation
  static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__first)>::value,
                                                            ^
/usr/include/c++/v1/__config:685:27: note: expanded from macro 'decltype'
#    define decltype(...) __decltype(__VA_ARGS__)
                          ^
/usr/include/sys/cdefs.h:284:9: note: macro '_Static_assert' defined here
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
        ^
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc:5:
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1750:
In file included from /usr/include/c++/v1/__algorithm/inplace_merge.h:16:
In file included from /usr/include/c++/v1/__algorithm/min.h:14:
/usr/include/c++/v1/__algorithm/min_element.h:55:51: error: expected '('
              "The comparator has to be callable");
                                                  ^
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc:5:
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1754:
/usr/include/c++/v1/__algorithm/is_permutation.h:191:70: error: too many arguments provided to function-like macro invocation
  static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value,
                                                                     ^
/usr/include/c++/v1/__config:685:27: note: expanded from macro 'decltype'
#    define decltype(...) __decltype(__VA_ARGS__)
                          ^
/usr/include/sys/cdefs.h:284:9: note: macro '_Static_assert' defined here
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
        ^
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc:5:
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1754:
/usr/include/c++/v1/__algorithm/is_permutation.h:192:42: error: expected '('
      "The predicate has to be callable");
                                         ^
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc:5:
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1767:
In file included from /usr/include/c++/v1/__algorithm/minmax.h:13:
/usr/include/c++/v1/__algorithm/minmax_element.h:87:61: error: too many arguments provided to function-like macro invocation
  static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__first)>::value,
                                                            ^
/usr/include/c++/v1/__config:685:27: note: expanded from macro 'decltype'
#    define decltype(...) __decltype(__VA_ARGS__)
                          ^
/usr/include/sys/cdefs.h:284:9: note: macro '_Static_assert' defined here
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
        ^
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc:5:
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1767:
In file included from /usr/include/c++/v1/__algorithm/minmax.h:13:
/usr/include/c++/v1/__algorithm/minmax_element.h:88:53: error: expected '('
                "The comparator has to be callable");
                                                    ^
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc:5:
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1776:
/usr/include/c++/v1/__algorithm/partial_sort_copy.h:68:61: error: too many arguments provided to function-like macro invocation
  static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__result_first)>::value,
                                                            ^
/usr/include/c++/v1/__config:685:27: note: expanded from macro 'decltype'
#    define decltype(...) __decltype(__VA_ARGS__)
                          ^
/usr/include/sys/cdefs.h:284:9: note: macro '_Static_assert' defined here
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
        ^
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc:5:
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1776:
/usr/include/c++/v1/__algorithm/partial_sort_copy.h:69:49: error: expected '('
                "Comparator has to be callable");
                                                ^
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/test/cxx03_test.cc:5:
In file included from /usr/ports/devel/benchmark/work/benchmark-1.8.0/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1853:
In file included from /usr/include/c++/v1/__algorithm/ranges_search_n.h:13:
/usr/include/c++/v1/__algorithm/search_n.h:166:69: error: too many arguments provided to function-like macro invocation
  static_assert(__is_callable<_BinaryPredicate, decltype(*__first), const _Tp&>::value,
                                                                    ^
/usr/include/sys/cdefs.h:284:9: note: macro '_Static_assert' defined here
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

Compiler version:

$ cc --version
FreeBSD clang version 15.0.7 (https://github.com/llvm/llvm-project.git llvmorg-15.0.7-0-g8dfdcc7b7bf6)
Target: x86_64-unknown-freebsd13.2
Thread model: posix
InstalledDir: /usr/bin
LebedevRI commented 1 year ago

(Does libc++ still support c++03, though?)

yurivict commented 1 year ago

(Does libc++ still support c++03, though?)

It should. Is there a way to test it?

LebedevRI commented 1 year ago

I'm not sure what the problem is, but i really don't see why it would be a benchmark-one. I think this is either a freebsd bug, or a libc++ one. The issue seems to be that /usr/include/sys/cdefs.h provides _Static_assert macro, and somehow it is incompatible with whatever is expected of it.

yurivict commented 1 year ago
#if !__has_extension(c_static_assert)
#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
    __has_extension(cxx_static_assert)
#define _Static_assert(x, y)    static_assert(x, y)
#elif __GNUC_PREREQ__(4,6) && !defined(__cplusplus)
/* Nothing, gcc 4.6 and higher has _Static_assert built-in */
#elif defined(__COUNTER__)
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
#define __Static_assert(x, y)   ___Static_assert(x, y)
#define ___Static_assert(x, y)  typedef char __assert_ ## y[(x) ? 1 : -1] \
                                __unused
#else
#define _Static_assert(x, y)    struct __hack
#endif
#endif
LebedevRI commented 1 year ago

Honestly, i can not even tell if the static_assert is actually failing, or those macros are buggy.

yurivict commented 1 year ago

1.8.1 has the same problem.

dmah42 commented 1 year ago

i just released 1.8.2 but i don't expect it to change anything here. do you need to use cxx03? maybe you can use a newer compiler and then we shouldn't be even trying to compile cxx03. actually, maybe that's the issue. maybe our >c++11 is not working right for freebsd and we shouldn't be trying to compile this test?

yurivict commented 1 year ago

1.8.2 has the same problem. We use clang-15. Tests compile successfully with gcc-12.

Do tests compile for you with clang-15 or any clang?

dmah42 commented 1 year ago

yes. https://github.com/google/benchmark/actions/runs/5473471377

LebedevRI commented 1 year ago

As i said, i strongly believe sys/cdefs.h is broken on that system.

yurivict commented 11 months ago

The immediate cause of the problem is that the "static_assert" macro existing since c++11 is used with -std=c++98. You use -std=c++98 for tests for some reason.

LebedevRI commented 11 months ago

The immediate cause of the problem is that the "static_assert" macro existing since c++11 is used with -std=c++98. You use -std=c++98 for tests for some reason.

Aha, now that does seem suspect. (I'm guessing you meant -std=c++11 though) I guess that macro needs to be wrapped:

#if __cplusplus >= 201103L
static_assert(<...>)
#endif

Would you like to submit a patch? :)

yurivict commented 11 months ago

No, 98 is explicitly set in CMakeLists.txt:

test/CMakeLists.txt: CXX_STANDARD 98

This is in direct conflict with "static_assert".

LebedevRI commented 11 months ago

Ah, did not know that. The suggestion still stands :)

dmah42 commented 10 months ago

for the cxx03_test we shouldn't be calling static_assert as it's not in c++03. given we're telling the compiler which standard to use, i'm surprised the header is attempting to static_assert.

changing the standard for the cxx03_test would run counter to the point of the test.

LebedevRI commented 10 months ago

That is what i said, we should guard static_assert with a preprocessor magic.

vedranmiletic commented 6 months ago

I would be glad to make this into a patch and send it as a pull request.

Ah, did not know that. The suggestion still stands :)

I tried doing that in test/basic_test.cc but it wasn't enough. Any suggestions?

LebedevRI commented 6 months ago

As far as i can tell, the failures are coming from inside of the libc++ headers, which means this is not a benchmark problem, but a FreeBSD one. Does this compile on FreeBSD: https://godbolt.org/z/xrvY8YsG8 ? I don't think it does.

Even if we guard all static_assert's in benchmark, the ones in libc++ will remain... Please report this to FreeBSD bugtracker (feel free to post a link to that bugreport here.)

vedranmiletic commented 6 months ago

As far as i can tell, the failures are coming from inside of the libc++ headers, which means this is not a benchmark problem, but a FreeBSD one. Does this compile on FreeBSD: https://godbolt.org/z/xrvY8YsG8 ? I don't think it does.

% uname -aKU
FreeBSD afrodite 14.0-RELEASE-p3 FreeBSD 14.0-RELEASE-p3 #0: Mon Dec 11 04:56:01 UTC 2023     root@amd64-builder.daemonology.net:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64 1400097 1400097
% c++ --version
FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152)
Target: x86_64-unknown-freebsd14.0
Thread model: posix
InstalledDir: /usr/bin
% cat xrvY8YsG8.cc
#include <algorithm>
% c++ -c xrvY8YsG8.cc
% c++ -c -std=c++98 xrvY8YsG8.cc
% c++ -c -std=gnu++98 xrvY8YsG8.cc
% c++ -c -std=c++03 xrvY8YsG8.cc
% c++ -c -std=gnu++03 xrvY8YsG8.cc

All compilations finish without errors.

LebedevRI commented 6 months ago

Hm, ok, on clean build dir for benchmark main branch, can you first run make -k0, and then (and post the output of) make -k0 -j1 ?

LebedevRI commented 6 months ago

Also, does https://godbolt.org/z/Y43GoaxnG compile?

vedranmiletic commented 6 months ago

Also, does https://godbolt.org/z/Y43GoaxnG compile?

Yes, as default, c++98, and gnu++98.

Hm, ok, on clean build dir for benchmark main branch, can you first run make -k0, and then (and post the output of) make -k0 -j1 ?

[ 18%] Built target benchmark
[ 20%] Built target benchmark_main
[ 22%] Built target output_test_helper
[ 24%] Built target benchmark_test
[ 26%] Built target spec_arg_test
[ 28%] Built target spec_arg_verbosity_test
[ 29%] Built target benchmark_setup_teardown_test
[ 31%] Built target filter_test
[ 33%] Built target benchmark_min_time_flag_time_test
[ 34%] Built target benchmark_min_time_flag_iters_test
[ 36%] Built target options_test
[ 38%] Built target basic_test
[ 40%] Built target repetitions_test
[ 41%] Built target diagnostics_test
[ 42%] Built target skip_with_error_test
[ 44%] Built target donotoptimize_test
[ 46%] Built target fixture_test
[ 47%] Built target register_benchmark_test
[ 50%] Built target map_test
[ 51%] Built target multiple_ranges_test
[ 52%] Built target args_product_test
[ 54%] Built target link_main_test
[ 56%] Built target reporter_output_test
[ 57%] Built target templated_fixture_test
[ 59%] Built target user_counters_test
[ 61%] Built target perf_counters_test
[ 62%] Built target internal_threading_test
[ 64%] Built target report_aggregates_only_test
[ 66%] Built target display_aggregates_only_test
[ 68%] Built target user_counters_tabular_test
[ 70%] Built target user_counters_thousands_test
[ 72%] Built target memory_manager_test
[ 73%] Building CXX object test/CMakeFiles/cxx03_test.dir/cxx03_test.cc.o
In file included from /home/vedran/workspace/benchmark/test/cxx03_test.cc:5:
In file included from /home/vedran/workspace/benchmark/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1713:
In file included from /usr/include/c++/v1/__algorithm/adjacent_find.h:14:
/usr/include/c++/v1/__algorithm/iterator_operations.h:104:9: error: too many arguments provided to function-like macro invocation
        "It looks like your iterator's `iterator_traits<It>::reference` does not match the return type of "
        ^
/usr/include/sys/cdefs.h:282:9: note: macro '_Static_assert' defined here
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
        ^
In file included from /home/vedran/workspace/benchmark/test/cxx03_test.cc:5:
In file included from /home/vedran/workspace/benchmark/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1713:
In file included from /usr/include/c++/v1/__algorithm/adjacent_find.h:14:
/usr/include/c++/v1/__algorithm/iterator_operations.h:106:90: error: expected '('
        "and can lead to dangling reference issues at runtime, so we are flagging this.");
                                                                                         ^
In file included from /home/vedran/workspace/benchmark/test/cxx03_test.cc:5:
In file included from /home/vedran/workspace/benchmark/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1716:
In file included from /usr/include/c++/v1/__algorithm/binary_search.h:14:
/usr/include/c++/v1/__algorithm/lower_bound.h:53:61: error: too many arguments provided to function-like macro invocation
  static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value,
                                                            ^
/usr/include/sys/cdefs.h:282:9: note: macro '_Static_assert' defined here
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
        ^
In file included from /home/vedran/workspace/benchmark/test/cxx03_test.cc:5:
In file included from /home/vedran/workspace/benchmark/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1716:
In file included from /usr/include/c++/v1/__algorithm/binary_search.h:14:
/usr/include/c++/v1/__algorithm/lower_bound.h:54:53: error: expected '('
                "The comparator has to be callable");
                                                    ^
In file included from /home/vedran/workspace/benchmark/test/cxx03_test.cc:5:
In file included from /home/vedran/workspace/benchmark/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1720:
In file included from /usr/include/c++/v1/__algorithm/copy.h:14:
In file included from /usr/include/c++/v1/__algorithm/min.h:14:
/usr/include/c++/v1/__algorithm/min_element.h:54:61: error: too many arguments provided to function-like macro invocation
  static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__first)>::value,
                                                            ^
/usr/include/c++/v1/__config:443:27: note: expanded from macro 'decltype'
#    define decltype(...) __decltype(__VA_ARGS__)
                          ^
/usr/include/sys/cdefs.h:282:9: note: macro '_Static_assert' defined here
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
        ^
In file included from /home/vedran/workspace/benchmark/test/cxx03_test.cc:5:
In file included from /home/vedran/workspace/benchmark/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1720:
In file included from /usr/include/c++/v1/__algorithm/copy.h:14:
In file included from /usr/include/c++/v1/__algorithm/min.h:14:
/usr/include/c++/v1/__algorithm/min_element.h:55:51: error: expected '('
              "The comparator has to be callable");
                                                  ^
In file included from /home/vedran/workspace/benchmark/test/cxx03_test.cc:5:
In file included from /home/vedran/workspace/benchmark/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1727:
/usr/include/c++/v1/__algorithm/equal_range.h:63:61: error: too many arguments provided to function-like macro invocation
  static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value,
                                                            ^
/usr/include/sys/cdefs.h:282:9: note: macro '_Static_assert' defined here
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
        ^
In file included from /home/vedran/workspace/benchmark/test/cxx03_test.cc:5:
In file included from /home/vedran/workspace/benchmark/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1727:
/usr/include/c++/v1/__algorithm/equal_range.h:64:53: error: expected '('
                "The comparator has to be callable");
                                                    ^
In file included from /home/vedran/workspace/benchmark/test/cxx03_test.cc:5:
In file included from /home/vedran/workspace/benchmark/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1731:
In file included from /usr/include/c++/v1/__algorithm/find_end.h:15:
/usr/include/c++/v1/__algorithm/search.h:177:70: error: too many arguments provided to function-like macro invocation
  static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value,
                                                                     ^
/usr/include/c++/v1/__config:443:27: note: expanded from macro 'decltype'
#    define decltype(...) __decltype(__VA_ARGS__)
                          ^
/usr/include/sys/cdefs.h:282:9: note: macro '_Static_assert' defined here
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
        ^
In file included from /home/vedran/workspace/benchmark/test/cxx03_test.cc:5:
In file included from /home/vedran/workspace/benchmark/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1731:
In file included from /usr/include/c++/v1/__algorithm/find_end.h:15:
/usr/include/c++/v1/__algorithm/search.h:178:54: error: expected '('
                "BinaryPredicate has to be callable");
                                                     ^
In file included from /home/vedran/workspace/benchmark/test/cxx03_test.cc:5:
In file included from /home/vedran/workspace/benchmark/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1746:
/usr/include/c++/v1/__algorithm/includes.h:48:62: error: too many arguments provided to function-like macro invocation
  static_assert(__is_callable<_Compare, decltype(*__first1), decltype(*__first2)>::value,
                                                             ^
/usr/include/c++/v1/__config:443:27: note: expanded from macro 'decltype'
#    define decltype(...) __decltype(__VA_ARGS__)
                          ^
/usr/include/sys/cdefs.h:282:9: note: macro '_Static_assert' defined here
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
        ^
In file included from /home/vedran/workspace/benchmark/test/cxx03_test.cc:5:
In file included from /home/vedran/workspace/benchmark/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1746:
/usr/include/c++/v1/__algorithm/includes.h:49:39: error: expected '('
      "Comparator has to be callable");
                                      ^
In file included from /home/vedran/workspace/benchmark/test/cxx03_test.cc:5:
In file included from /home/vedran/workspace/benchmark/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1747:
In file included from /usr/include/c++/v1/__algorithm/inplace_merge.h:28:
In file included from /usr/include/c++/v1/__memory/unique_ptr.h:19:
/usr/include/c++/v1/__memory/allocator_traits.h:166:54: error: too many arguments provided to function-like macro invocation
  static_assert(__has_rebind_other<_Tp, _Up>::value, "This allocator has to implement rebind");
                                                     ^
/usr/include/sys/cdefs.h:282:9: note: macro '_Static_assert' defined here
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
        ^
In file included from /home/vedran/workspace/benchmark/test/cxx03_test.cc:5:
In file included from /home/vedran/workspace/benchmark/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1747:
In file included from /usr/include/c++/v1/__algorithm/inplace_merge.h:28:
In file included from /usr/include/c++/v1/__memory/unique_ptr.h:19:
/usr/include/c++/v1/__memory/allocator_traits.h:166:95: error: expected '('
  static_assert(__has_rebind_other<_Tp, _Up>::value, "This allocator has to implement rebind");
                                                                                              ^
In file included from /home/vedran/workspace/benchmark/test/cxx03_test.cc:5:
In file included from /home/vedran/workspace/benchmark/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1751:
/usr/include/c++/v1/__algorithm/is_permutation.h:191:70: error: too many arguments provided to function-like macro invocation
  static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value,
                                                                     ^
/usr/include/c++/v1/__config:443:27: note: expanded from macro 'decltype'
#    define decltype(...) __decltype(__VA_ARGS__)
                          ^
/usr/include/sys/cdefs.h:282:9: note: macro '_Static_assert' defined here
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
        ^
In file included from /home/vedran/workspace/benchmark/test/cxx03_test.cc:5:
In file included from /home/vedran/workspace/benchmark/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1751:
/usr/include/c++/v1/__algorithm/is_permutation.h:192:42: error: expected '('
      "The predicate has to be callable");
                                         ^
In file included from /home/vedran/workspace/benchmark/test/cxx03_test.cc:5:
In file included from /home/vedran/workspace/benchmark/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1764:
In file included from /usr/include/c++/v1/__algorithm/minmax.h:13:
/usr/include/c++/v1/__algorithm/minmax_element.h:87:61: error: too many arguments provided to function-like macro invocation
  static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__first)>::value,
                                                            ^
/usr/include/c++/v1/__config:443:27: note: expanded from macro 'decltype'
#    define decltype(...) __decltype(__VA_ARGS__)
                          ^
/usr/include/sys/cdefs.h:282:9: note: macro '_Static_assert' defined here
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
        ^
In file included from /home/vedran/workspace/benchmark/test/cxx03_test.cc:5:
In file included from /home/vedran/workspace/benchmark/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1764:
In file included from /usr/include/c++/v1/__algorithm/minmax.h:13:
/usr/include/c++/v1/__algorithm/minmax_element.h:88:53: error: expected '('
                "The comparator has to be callable");
                                                    ^
In file included from /home/vedran/workspace/benchmark/test/cxx03_test.cc:5:
In file included from /home/vedran/workspace/benchmark/include/benchmark/benchmark.h:179:
In file included from /usr/include/c++/v1/algorithm:1773:
/usr/include/c++/v1/__algorithm/partial_sort_copy.h:68:61: error: too many arguments provided to function-like macro invocation
  static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__result_first)>::value,
                                                            ^
/usr/include/c++/v1/__config:443:27: note: expanded from macro 'decltype'
#    define decltype(...) __decltype(__VA_ARGS__)
                          ^
/usr/include/sys/cdefs.h:282:9: note: macro '_Static_assert' defined here
#define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
*** [test/CMakeFiles/cxx03_test.dir/cxx03_test.cc.o] Error code 1

make[2]: stopped in /home/vedran/workspace/benchmark/build
1 error

make[2]: stopped in /home/vedran/workspace/benchmark/build
*** [test/CMakeFiles/cxx03_test.dir/all] Error code 2

make[1]: stopped in /home/vedran/workspace/benchmark/build
1 error

make[1]: stopped in /home/vedran/workspace/benchmark/build
*** [all] Error code 2

make: stopped in /home/vedran/workspace/benchmark/build

make: stopped in /home/vedran/workspace/benchmark/build
LebedevRI commented 6 months ago

Thank you!

As far as i can tell, cxx03 test does exactly what it is supposed to, it caught that the library is not usable in C++03 mode.

As far as i can tell, everything there points at libc++ / FreeBSD's sys/cdefs.h. Let them deal with it, or let them explain what we are doing wrong.

Please forward this to FreeBSD bugtracker.

hmenke commented 5 months ago

Here is a patch.

diff --git a/test/cxx03_test.cc b/test/cxx03_test.cc
index 9711c1b..8461fb7 100644
--- a/test/cxx03_test.cc
+++ b/test/cxx03_test.cc
@@ -2,6 +2,11 @@
 #include <cassert>
 #include <cstddef>

+// https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=276738
+#ifdef _LIBCPP_VERSION
+#undef _Static_assert
+#endif
+
 #include "benchmark/benchmark.h"

 #if __cplusplus >= 201103L
LebedevRI commented 5 months ago

Thank you!

See, told ya. libc++ does not support pre-C++11, and this is a FreeBSD bug... I'm not okay with that patch, this really is an upstream problem.

hmenke commented 5 months ago

But shouldn't the test be skipped then when using libc++?

LebedevRI commented 5 months ago

I mean. macos CI, which uses libc++, is happy. mingw libc++-based CI is happy. linux sanitized (thus, libc++-based) builds are happy.

bsdimp commented 1 month ago

https://reviews.freebsd.org/D45650

It's a conflict between two different bits of software thinking they are the owners of the implementation name space.