Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests fail to compile: error: 'ret_count' is an unsafe buffer that does not perform bounds checks #322

Open
yurivict opened this issue Nov 7, 2023 · 3 comments

Comments

@yurivict
Copy link

yurivict commented Nov 7, 2023

clang-16 fails:

/usr/ports/devel/trompeloeil/work/trompeloeil-46/test/thread_terror.cpp:30:33: error: 'ret_count' is an unsafe buffer that does not perform bounds checks [-Werror,-Wunsafe-buffer-usage]
static std::atomic<std::size_t> ret_count[7];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
/usr/ports/devel/trompeloeil/work/trompeloeil-46/test/thread_terror.cpp:56:7: note: used in buffer access here
      ret_count[m->func()]++;
      ^~~~~~~~~
/usr/ports/devel/trompeloeil/work/trompeloeil-46/test/thread_terror.cpp:29:33: error: 'call_count' is an unsafe buffer that does not perform bounds checks [-Werror,-Wunsafe-buffer-usage]
static std::atomic<std::size_t> call_count[7];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
/usr/ports/devel/trompeloeil/work/trompeloeil-46/include/trompeloeil.hpp:3869:7: note: in instantiation of function template specialization 'allow(size_t, int)::(anonymous class)::operator()<std::tuple<>>' requested here
      a(t);
      ^
/usr/ports/devel/trompeloeil/work/trompeloeil-46/include/trompeloeil.hpp:3858:5: note: in instantiation of member function 'trompeloeil::side_effect<int (), (lambda at /usr/ports/devel/trompeloeil/work/trompeloeil-46/test/thread_terror.cpp:69:10)>::action' requested here
    side_effect(
    ^
/usr/ports/devel/trompeloeil/work/trompeloeil-46/include/trompeloeil.hpp:4548:25: note: in instantiation of function template specialization 'trompeloeil::side_effect<int (), (lambda at /usr/ports/devel/trompeloeil/work/trompeloeil-46/test/thread_terror.cpp:69:10)>::side_effect<(lambda at /usr/ports/devel/trompeloeil/work/trompeloeil-46/test/thread_terror.cpp:69:10)>' requested here
      auto effect = new side_effect<Sig, S>(std::forward<S>(s));
                        ^
/usr/ports/devel/trompeloeil/work/trompeloeil-46/include/trompeloeil.hpp:3958:16: note: in instantiation of function template specialization 'trompeloeil::call_matcher<int (), std::tuple<>>::add_side_effect<(lambda at /usr/ports/devel/trompeloeil/work/trompeloeil-46/test/thread_terror.cpp:69:10)>' requested here
      matcher->add_side_effect(std::forward<A>(a));
               ^
/usr/ports/devel/trompeloeil/work/trompeloeil-46/test/thread_terror.cpp:69:10: note: in instantiation of function template specialization 'trompeloeil::call_modifier<trompeloeil::call_matcher<int (), std::tuple<>>, C::trompeloeil_l_tag_type_trompeloeil_11, trompeloeil::call_limit_injector<trompeloeil::matcher_info<int ()>, 18446744073709551615>>::sideeffect<(lambda at /usr/ports/devel/trompeloeil/work/trompeloeil-46/test/thread_terror.cpp:69:10)>' requested here
        .SIDE_EFFECT(++call_count[id])
         ^
/usr/ports/devel/trompeloeil/work/trompeloeil-46/include/trompeloeil.hpp:5890:35: note: expanded from macro 'SIDE_EFFECT'
#define SIDE_EFFECT               TROMPELOEIL_SIDE_EFFECT
                                  ^
/usr/ports/devel/trompeloeil/work/trompeloeil-46/include/trompeloeil.hpp:5515:41: note: expanded from macro 'TROMPELOEIL_SIDE_EFFECT'
#define TROMPELOEIL_SIDE_EFFECT(...)    TROMPELOEIL_SIDE_EFFECT_(=, __VA_ARGS__)
                                        ^
/usr/ports/devel/trompeloeil/work/trompeloeil-46/include/trompeloeil.hpp:5549:3: note: expanded from macro 'TROMPELOEIL_SIDE_EFFECT_'
  sideeffect([capture](auto& trompeloeil_x) {                                  \
  ^
/usr/ports/devel/trompeloeil/work/trompeloeil-46/test/thread_terror.cpp:69:24: note: used in buffer access here
        .SIDE_EFFECT(++call_count[id])
                       ^~~~~~~~~~
/usr/ports/devel/trompeloeil/work/trompeloeil-46/include/trompeloeil.hpp:5890:35: note: expanded from macro 'SIDE_EFFECT'
#define SIDE_EFFECT               TROMPELOEIL_SIDE_EFFECT
                                  ^
/usr/ports/devel/trompeloeil/work/trompeloeil-46/include/trompeloeil.hpp:5515:69: note: expanded from macro 'TROMPELOEIL_SIDE_EFFECT'
#define TROMPELOEIL_SIDE_EFFECT(...)    TROMPELOEIL_SIDE_EFFECT_(=, __VA_ARGS__)
                                                                    ^~~~~~~~~~~
/usr/ports/devel/trompeloeil/work/trompeloeil-46/include/trompeloeil.hpp:5566:5: note: expanded from macro 'TROMPELOEIL_SIDE_EFFECT_'
    __VA_ARGS__;                                                               \
    ^~~~~~~~~~~
2 errors generated.

Version: 46

@rollbear
Copy link
Owner

rollbear commented Nov 8, 2023

Right. Thank you for reporting. I'll get back to you.

@rollbear
Copy link
Owner

rollbear commented Nov 8, 2023

Please have a look at branch fix_322 to ensure that the issue has indeed been solved there.

@rollbear
Copy link
Owner

I've merged this to main now. Leaving it open until a release has been tagged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants