public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/50486] New: No warning at signed -> unsigned casting
@ 2011-09-22 14:44 kirill at shutemov dot name
2011-09-22 15:26 ` [Bug c/50486] " manu at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: kirill at shutemov dot name @ 2011-09-22 14:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50486
Bug #: 50486
Summary: No warning at signed -> unsigned casting
Classification: Unclassified
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: kirill@shutemov.name
$ cat 1.c
enum e {
A,
B,
C
};
int a(enum e e)
{
if (e < 0)
return 1;
return 0;
}
int b(void)
{
return a(-1);
}
Since enum e has only positive values GCC states that enum is unsigned and
eliminates the if-check. I can see warning about it with -Wtype-limits.
But GCC generates no warning at a(-1), so it silently casts -1 to unsigned.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/50486] No warning at signed -> unsigned casting
2011-09-22 14:44 [Bug c/50486] New: No warning at signed -> unsigned casting kirill at shutemov dot name
@ 2011-09-22 15:26 ` manu at gcc dot gnu.org
2022-04-10 22:07 ` egallager at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: manu at gcc dot gnu.org @ 2011-09-22 15:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50486
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011-09-22
CC| |manu at gcc dot gnu.org
Ever Confirmed|0 |1
--- Comment #1 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-09-22 15:02:46 UTC ---
-1 is converted to 4294967295 very early in the FE, but I don't know why or
where.
I think Wsign-conversion could warn about this. I will confirm it then, but I
am not working on it.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/50486] No warning at signed -> unsigned casting
2011-09-22 14:44 [Bug c/50486] New: No warning at signed -> unsigned casting kirill at shutemov dot name
2011-09-22 15:26 ` [Bug c/50486] " manu at gcc dot gnu.org
@ 2022-04-10 22:07 ` egallager at gcc dot gnu.org
2022-04-11 12:51 ` manu at gcc dot gnu.org
2023-05-31 2:24 ` [Bug c/50486] Missed -Wsign-conversion with signed -> unsigned casting and enums egallager at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: egallager at gcc dot gnu.org @ 2022-04-10 22:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50486
Eric Gallager <egallager at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |egallager at gcc dot gnu.org
--- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Manuel López-Ibáñez from comment #1)
> -1 is converted to 4294967295 very early in the FE, but I don't know why or
> where.
>
> I think Wsign-conversion could warn about this. I will confirm it then, but
> I am not working on it.
...or, now that there's a -Wenum-conversion flag, how about that?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/50486] No warning at signed -> unsigned casting
2011-09-22 14:44 [Bug c/50486] New: No warning at signed -> unsigned casting kirill at shutemov dot name
2011-09-22 15:26 ` [Bug c/50486] " manu at gcc dot gnu.org
2022-04-10 22:07 ` egallager at gcc dot gnu.org
@ 2022-04-11 12:51 ` manu at gcc dot gnu.org
2023-05-31 2:24 ` [Bug c/50486] Missed -Wsign-conversion with signed -> unsigned casting and enums egallager at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: manu at gcc dot gnu.org @ 2022-04-11 12:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50486
--- Comment #3 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
Clang warns:
<source>:16:18: warning: implicit conversion changes signedness: 'int' to
'enum e' [-Wsign-conversion]
return a(-1);
~ ^~
Not sure why gcc doesn't but it should.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/50486] Missed -Wsign-conversion with signed -> unsigned casting and enums
2011-09-22 14:44 [Bug c/50486] New: No warning at signed -> unsigned casting kirill at shutemov dot name
` (2 preceding siblings ...)
2022-04-11 12:51 ` manu at gcc dot gnu.org
@ 2023-05-31 2:24 ` egallager at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: egallager at gcc dot gnu.org @ 2023-05-31 2:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50486
Eric Gallager <egallager at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|No warning at signed -> |Missed -Wsign-conversion
|unsigned casting |with signed -> unsigned
| |casting and enums
--- Comment #4 from Eric Gallager <egallager at gcc dot gnu.org> ---
updating the title a bit
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-05-31 2:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-22 14:44 [Bug c/50486] New: No warning at signed -> unsigned casting kirill at shutemov dot name
2011-09-22 15:26 ` [Bug c/50486] " manu at gcc dot gnu.org
2022-04-10 22:07 ` egallager at gcc dot gnu.org
2022-04-11 12:51 ` manu at gcc dot gnu.org
2023-05-31 2:24 ` [Bug c/50486] Missed -Wsign-conversion with signed -> unsigned casting and enums egallager at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).