Explicit casts to avoid conversion warnings [blocks: #2310]#2551
Explicit casts to avoid conversion warnings [blocks: #2310]#2551tautschnig wants to merge 8 commits intodiffblue:developfrom
Conversation
|
These really can't be silenced with an explicit typecast? |
|
Also a lot of these don't appear to be related to standard library calls? |
allredj
left a comment
There was a problem hiding this comment.
Passed Diffblue compatibility checks (cbmc commit: 5d40b60).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/78358680
2acc9aa to
bace090
Compare
bace090 to
db43e7a
Compare
|
This is now re-implemented using explicit type casts. |
allredj
left a comment
There was a problem hiding this comment.
✔️
Passed Diffblue compatibility checks (cbmc commit: db43e7a).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/95906397
b72b9d0 to
7c61bdb
Compare
allredj
left a comment
There was a problem hiding this comment.
✔️
Passed Diffblue compatibility checks (cbmc commit: c332386).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102222178
c332386 to
d96a361
Compare
allredj
left a comment
There was a problem hiding this comment.
This PR failed Diffblue compatibility checks (cbmc commit: d96a361).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/104504752
Status will be re-evaluated on next push.
Common spurious failures:
-
the cbmc commit has disappeared in the mean time (e.g. in a force-push)
-
the author is not in the list of contributors (e.g. first-time contributors).
-
the compatibility was already broken by an earlier merge.
d96a361 to
13856db
Compare
allredj
left a comment
There was a problem hiding this comment.
✔️
Passed Diffblue compatibility checks (cbmc commit: 13856db).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/106408234
thk123
left a comment
There was a problem hiding this comment.
A couple of changes I think you should double check, but otherwise lgtm
| for(unsigned i=0; i<src.size(); i++) | ||
| { | ||
| T ch=(unsigned char)src[i]; | ||
| T ch = narrow_cast<T>(narrow_cast<unsigned char>(src[i])); |
There was a problem hiding this comment.
❓ Why narrow to unsigned char first? 🐭
There was a problem hiding this comment.
This is to preserve the existing behaviour, as T might actually be wider than unsigned char. That said, I guess narrow_cast would fail in a case where that makes a difference, so I can probably get rid of it.
There was a problem hiding this comment.
Nested cast removed.
| assert(i<src.size()); // backslash can't be last character | ||
|
|
||
| ch=(unsigned char)src[i]; | ||
| ch = narrow_cast<T>(narrow_cast<unsigned char>(src[i])); |
| if(elf_reader.section_name(i)=="goto-cc") | ||
| { | ||
| in.seekg(elf_reader.section_offset(i)); | ||
| in.seekg(std::streamoff{elf_reader.section_offset(i)}); |
There was a problem hiding this comment.
❓ Is this change meant to be here?
There was a problem hiding this comment.
Yes, because section_offset returns a std::streampos (which makes sense in other contexts).
02abb9a to
36b9d0c
Compare
allredj
left a comment
There was a problem hiding this comment.
✔️
Passed Diffblue compatibility checks (cbmc commit: 36b9d0c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/113768512
Visual Studio warns about signed/unsigned conversion and limited range of types.
Visual Studio warns about signed/unsigned conversion and limited range of types.
Visual Studio warns about signed/unsigned conversion and limited range of types.
Visual Studio warns about signed/unsigned conversion and limited range of types.
Visual Studio warns about signed/unsigned conversion and limited range of types.
…d long long Visual Studio warns about signed/unsigned conversion and limited range of types.
This avoids conversion warnings with Visual Studio.
If the inner cast actually had any effect then that would amount to a loss of precision, which in turn would necessarily fail with narrrow_cast.
36b9d0c to
bf8ae77
Compare
allredj
left a comment
There was a problem hiding this comment.
This PR failed Diffblue compatibility checks (cbmc commit: bf8ae77).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/113953221
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.
|
Closing due to age (no further comment on PR content), please reopen with rebase on develop if you intent to continue this work. |
Visual Studio warns about signed/unsigned conversion and limited range of types.