public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/103447] New: left shift operator gives wrong result for shift of 48
@ 2021-11-27 0:06 pgmer6809 at yahoo dot com
2021-11-27 0:13 ` [Bug c/103447] " pinskia at gcc dot gnu.org
2021-11-27 0:58 ` pgmer6809 at yahoo dot com
0 siblings, 2 replies; 3+ messages in thread
From: pgmer6809 at yahoo dot com @ 2021-11-27 0:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103447
Bug ID: 103447
Summary: left shift operator gives wrong result for shift of 48
Product: gcc
Version: 9.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: pgmer6809 at yahoo dot com
Target Milestone: ---
Created attachment 51886
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51886&action=edit
results of the gcc -v save-temps
GCC cannot handle the statement:
unsigned long long int two48 = 1<<48
on a 64 bit machine with sizeof (two48) = 8.
However it can handle the following fragment:
unsigned long long int two16, two48;
two16 = 256 * 256;
two48=two16*two16*two16 ;
See below
I wanted to attach all the files but I can only attach one.
You said not to make archive or zip files so there it is. No .s or .i file
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c/103447] left shift operator gives wrong result for shift of 48
2021-11-27 0:06 [Bug c/103447] New: left shift operator gives wrong result for shift of 48 pgmer6809 at yahoo dot com
@ 2021-11-27 0:13 ` pinskia at gcc dot gnu.org
2021-11-27 0:58 ` pgmer6809 at yahoo dot com
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-27 0:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103447
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Use 1ll<<48 to get the right value. 1 by itself is of type int which is 32 bit
so you are shifting outside of the bounds and there for it is undefined.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c/103447] left shift operator gives wrong result for shift of 48
2021-11-27 0:06 [Bug c/103447] New: left shift operator gives wrong result for shift of 48 pgmer6809 at yahoo dot com
2021-11-27 0:13 ` [Bug c/103447] " pinskia at gcc dot gnu.org
@ 2021-11-27 0:58 ` pgmer6809 at yahoo dot com
1 sibling, 0 replies; 3+ messages in thread
From: pgmer6809 at yahoo dot com @ 2021-11-27 0:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103447
--- Comment #2 from Greg Morse <pgmer6809 at yahoo dot com> ---
Thanks for the v. quick reply. I feel like an idiot.G. M.
On Friday, November 26, 2021, 04:13:45 p.m. PST, pinskia at gcc dot gnu.org
<gcc-bugzilla@gcc.gnu.org> wrote:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103447
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Use 1ll<<48 to get the right value. 1 by itself is of type int which is 32 bit
so you are shifting outside of the bounds and there for it is undefined.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-27 0:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-27 0:06 [Bug c/103447] New: left shift operator gives wrong result for shift of 48 pgmer6809 at yahoo dot com
2021-11-27 0:13 ` [Bug c/103447] " pinskia at gcc dot gnu.org
2021-11-27 0:58 ` pgmer6809 at yahoo dot com
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).