[Bug c/92857] -Wsign-conversion flag issues false positives for expression using typedef'ed unsigned types

2019-12-09 Thread joshua.a.saxby at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92857

Joshua Saxby  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #5 from Joshua Saxby  ---
Ah, I have some reading to do, then. Thank you for pointing that out and
apologies for wasting your time everyone.

[Bug c/92857] -Wsign-conversion flag issues false positives for expression using typedef'ed unsigned types

2019-12-09 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92857

--- Comment #4 from Andrew Pinski  ---
(In reply to Joshua Saxby from comment #2)
> (In reply to Richard Biener from comment #1)
> > I think the warning is about foo - bar being carried out in type 'int' due 
> > to
> > integer promotion and that converted to size_t which may turn the negative
> > result into a positive.
> 
> That could be the issue, although I would expect the integer promotion to
> promote to an unsigned integer type rather than a signed one. Am I mistaken
> in this assumption?

YES you are.  If a type is smaller than int and fits into int, then it is
prompoted to int (and not unsigned int).

[Bug c/92857] -Wsign-conversion flag issues false positives for expression using typedef'ed unsigned types

2019-12-09 Thread joshua.a.saxby at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92857

--- Comment #3 from Joshua Saxby  ---
I can confirm that if `MyUnsigned` is changed to `unsigned char`, the issue
persists, however if it is changed to `unsigned int`, the issue is not present.

[Bug c/92857] -Wsign-conversion flag issues false positives for expression using typedef'ed unsigned types

2019-12-09 Thread joshua.a.saxby at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92857

--- Comment #2 from Joshua Saxby  ---
(In reply to Richard Biener from comment #1)
> I think the warning is about foo - bar being carried out in type 'int' due to
> integer promotion and that converted to size_t which may turn the negative
> result into a positive.

That could be the issue, although I would expect the integer promotion to
promote to an unsigned integer type rather than a signed one. Am I mistaken in
this assumption?

I don't know if it makes a difference, but if `MyUnsigned` is replaced with
`unsigned`, then the warning diagnostic is not issued.

Then again, to demonstrate if it is an issue with the integer promotion or not,
probably it should be tested with `unsigned char` as well.

[Bug c/92857] -Wsign-conversion flag issues false positives for expression using typedef'ed unsigned types

2019-12-09 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92857

Richard Biener  changed:

   What|Removed |Added

   Keywords||diagnostic
  Known to fail||9.2.0

--- Comment #1 from Richard Biener  ---
I think the warning is about foo - bar being carried out in type 'int' due to
integer promotion and that converted to size_t which may turn the negative
result into a positive.