Reputation: 3
my thought is just like this question. i code isTmax like this:
int isTmax(int x) {
return !((~x)+(~x)); // it should be right, the operator "!" seem to not work
}
x is 2s complement, 32-bit representations of integers when i use btest to test function, it generate as follows:
ERROR: Test isTmax(2147483647[0x7fffffff]) failed... ...Gives 0[0x0]. Should be 1[0x1]
my question is: why 0? it seems like ! not work.
additionally, i get warning when running btest:
btest.c: In function ‘test_function’: btest.c:334:23: warning: ‘arg_test_range’ may be used uninitialized [-Wmaybe-uninitialized] 334 | if (arg_test_range[2] < 1) | ~~~~~~~~~~~~~~^~~ btest.c:299:9: note: ‘arg_test_range’ declared here 299 | int arg_test_range[3]; /* test range for each argument */ | ^~~~~~~~~~~~~~
maybe there is something wrong with my lab environment?
Upvotes: -1
Views: 409
Reputation: 9
This is only a warning message and does not affect your test. You can use -w
in the makefile to ignore this warning
Upvotes: -1