bpo-29939: suppress compiler warnings in _ctypes_test#902
Conversation
e.g.: _ctypes_test.c:53:42: warning: parameter ‘in’ set but not used [-Wunused-but-set-parameter]
vsajip
left a comment
There was a problem hiding this comment.
On my system, at least, you can avoid the warning with just the simple:
(void) in; /* avoid compiler warning */
in.first = 0x0badf00d;
in.second = 0x0badf00d;
in.third = 0x0badf00d;
in the body of the function. Any reason that isn't preferable?
|
The main advantage is that it forces the compiler to generate code to write the struct argument, which I gather is part of the reason for the test. If you don't care, you might as well remove the assignments in the body of the function—you can bet the compiler will with the current code—and avoid the warnings in the first place. |
|
Interesting. Before I put in the fix which this test exercises, I added this test, and it failed - indicating that the compiler was generating the code to write to the struct argument. After I put in the fix, the test started passing. Perhaps I've missed something there. If you are finding that the compiler optimises out all the assignments, what compiler version/compiler flags/architecture are you using? It would be useful to know. My testing was done with Ubuntu 16.04 x86_64 with stock gcc. |
|
|
Can't argue with that :-) I'm probably mis-remembering what happened when I did the test. |
e.g.: _ctypes_test.c:53:42: warning: parameter ‘in’ set but not used [-Wunused-but-set-parameter]