-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Test for is_buffer_sequence: false positives #402
Test for is_buffer_sequence: false positives #402
Conversation
typename enable_if<!is_same< | ||
decltype(asio::buffer_sequence_end(*t)), | ||
void>::value>::type*); | ||
void>::value>::type*))[2]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
sizeof(buffer_sequence_begin_helper<T>(0)) != 1 && | ||
sizeof(buffer_sequence_end_helper<T>(0)) != 1 && | ||
sizeof(buffer_sequence_begin_helper<T>(0, 0)) != 1 && | ||
sizeof(buffer_sequence_end_helper<T>(0, 0)) != 1 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the fallback becomes char[2]
not char
, so should it not be !=2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When called with single argument this is resolved to the fallback, since no default argument value in checker function declaration is specified. The fallback was char[2]
, the condition was true regardless of the type being tested.
The modified fallback for ASIO_HAS_DECLTYPE
case is char
, so != 1
is correct.
When ASIO_HAS_DECLTYPE
is not defined, fallback is still char[2]
, but in this case checker function must be rejected for acceptable type; != 1
is correct again.
typename enable_if<!is_same< | ||
decltype(asio::buffer_sequence_begin(*t)), | ||
void>::value>::type*); | ||
void>::value>::type*))[2]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fallback is now char
when ASIO_HAS_DECLTYPE
is defined (see above).
For checker function we need char[2]
I am not sure why do you say it, Have looked at your test-code, here is my observation and correct me if am wrong so you have the below stuff
I believe Here is my experiment on |
When I add To change this we can provide default value for its second argument (or add second argument when it is called from After such a change we need also invert condition, and write So instead of |
|
I would interpret this situation a bit differently. The test (055c51f) is written with assumption that Or perhaps the assumption used in the test is wrong? |
Obsoleted by #403 |
Simple test cases indicate that the
is_buffer_sequence
template is implemented incorrectly:struct A1
with single member is recognized as a MutableBufferSequence when compile with thedecltype
available;struct B1
with inappropriate typedefs and no member functions is recognized as a MutableBufferSequence when thedecltype
is unavailable or disabled.