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

Using FAKE_VOID_FUNC on vsyslog cause a sizeof-array-argument error #75

Open
ykoehler opened this issue May 9, 2019 · 4 comments
Open

Comments

@ykoehler
Copy link

ykoehler commented May 9, 2019

Describe the bug
FAKE_VALUE_FUNC(vsyslog, int, const char*, va_list);

is causing a sizeof of va_list which gcc turns into an error and therefore trigger the error sizeof-array-argument

To Reproduce
Compile the above

Expected behavior
detect array type and not call sizeof on them?

Screenshots
In file included from /home/ykoehler/fake_log.cpp:18:
/home/ykoehler/fake_log.cpp: In function ‘void vsyslog(int, const char*, __va_list_tag*)’:
/home/ykoehler/fff/include/fff.h:69:79: error: ‘sizeof’ on array function parameter ‘arg2’ will return size of ‘__va_list_tag*’ [-Werror=sizeof-array-argument]
memcpy((void*)&FUNCNAME##_fake.arg##n##_val, (void*)&arg##n, sizeof(arg##n));

Compiler, toolset, platform (please complete the following information):

  • OS: Ubuntu 18.10
  • Compiler: gcc (Ubuntu 8.2.0-7ubuntu1)

Additional context

@ballenthin
Copy link

I run into the same issues, is there already a work-a-round available?

@tastymushroom
Copy link

tastymushroom commented Jun 10, 2020

Same here.
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

Did anyone come up with a solution yet? Thanks.

GREAT Framework BTW Mike. Only found it recently!

@alukichev
Copy link

Looks like it's hard to find info on mocking functions that take array arguments. typedef array to a user type for them results precisely in the reported error.

@jerry90908
Copy link

jerry90908 commented Mar 30, 2023

Similar issue here.
When original function input argument is 1D array, in previous compiler version(7.5.0), I was able to use pointer type to fake it.
However in gcc version 11.3.0, the following error is complained by the compiler,

fff.h:1680:64: error: argument 1 of type ‘uint8_t *’ {aka ‘unsigned char *’} declared as a pointer [-Werror=array-parameter=]

gcc version: cc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0

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

No branches or pull requests

5 participants