* [Bug 80266] Undefined operation in tgsi_ureg.c left shift of 1 by 31 places cannot be represented in type 'int'
[not found] ` <bug-80266-8800-V0hAGp6uBxMKqLRl/0Ahz6D7qz1kEfGD2LY78lusg7I@public.gmane.org/>
@ 2014-06-20 5:48 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
2014-06-20 9:50 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ @ 2014-06-20 5:48 UTC (permalink / raw)
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
[-- Attachment #1.1: Type: text/plain, Size: 654 bytes --]
https://bugs.freedesktop.org/show_bug.cgi?id=80266
--- Comment #1 from Ilia Mirkin <imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org> ---
(In reply to comment #0)
> In tgsi_ureg.c:1498
> "if (ureg->vs_inputs[i/32] & (1 << (i%32))) {"
> when i==31 then 1 << 31 may be computed.
> With gcc option -std=c99 this is wrong because the result cannot be int.
>
> Perhaps the right instruction is
> "if (ureg->vs_inputs[i/32] & ((unsigned) 1 << (i%32))) {"
Where is -std=c99 coming from? Also I'd guess the better thing is 1U instead of
(unsigned)1 :)
Feel free to send a patch btw.
--
You are receiving this mail because:
You are the assignee for the bug.
[-- Attachment #1.2: Type: text/html, Size: 1640 bytes --]
[-- Attachment #2: Type: text/plain, Size: 181 bytes --]
_______________________________________________
Nouveau mailing list
Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 11+ messages in thread* [Bug 80266] Undefined operation in tgsi_ureg.c left shift of 1 by 31 places cannot be represented in type 'int'
[not found] ` <bug-80266-8800-V0hAGp6uBxMKqLRl/0Ahz6D7qz1kEfGD2LY78lusg7I@public.gmane.org/>
2014-06-20 5:48 ` [Bug 80266] " bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
@ 2014-06-20 9:50 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
2014-06-20 11:53 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ @ 2014-06-20 9:50 UTC (permalink / raw)
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
[-- Attachment #1.1: Type: text/plain, Size: 435 bytes --]
https://bugs.freedesktop.org/show_bug.cgi?id=80266
--- Comment #2 from Vittorio <zeccav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> ---
Yes I agree that 1U is better. My C knowledge is limited, I am more
interested into Fortran.
-std=c99 is in CFLAGS in the Makefile produced by configure and configure.ac.
Not much familiar with patch, please help yourself.
--
You are receiving this mail because:
You are the assignee for the bug.
[-- Attachment #1.2: Type: text/html, Size: 1271 bytes --]
[-- Attachment #2: Type: text/plain, Size: 181 bytes --]
_______________________________________________
Nouveau mailing list
Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 11+ messages in thread* [Bug 80266] Undefined operation in tgsi_ureg.c left shift of 1 by 31 places cannot be represented in type 'int'
[not found] ` <bug-80266-8800-V0hAGp6uBxMKqLRl/0Ahz6D7qz1kEfGD2LY78lusg7I@public.gmane.org/>
2014-06-20 5:48 ` [Bug 80266] " bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
2014-06-20 9:50 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
@ 2014-06-20 11:53 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
2014-06-20 18:12 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ @ 2014-06-20 11:53 UTC (permalink / raw)
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
[-- Attachment #1.1: Type: text/plain, Size: 378 bytes --]
https://bugs.freedesktop.org/show_bug.cgi?id=80266
--- Comment #3 from Vittorio <zeccav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> ---
For the same reason I believe that in uniforms.c:79
"if (prog->SamplersUsed & (1 << s)) {" should be
"if (prog->SamplersUsed & (1U << s)) {".
This is running glxgears.
--
You are receiving this mail because:
You are the assignee for the bug.
[-- Attachment #1.2: Type: text/html, Size: 1260 bytes --]
[-- Attachment #2: Type: text/plain, Size: 181 bytes --]
_______________________________________________
Nouveau mailing list
Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 11+ messages in thread* [Bug 80266] Undefined operation in tgsi_ureg.c left shift of 1 by 31 places cannot be represented in type 'int'
[not found] ` <bug-80266-8800-V0hAGp6uBxMKqLRl/0Ahz6D7qz1kEfGD2LY78lusg7I@public.gmane.org/>
` (2 preceding siblings ...)
2014-06-20 11:53 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
@ 2014-06-20 18:12 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
2014-06-20 18:18 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ @ 2014-06-20 18:12 UTC (permalink / raw)
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
[-- Attachment #1.1: Type: text/plain, Size: 441 bytes --]
https://bugs.freedesktop.org/show_bug.cgi?id=80266
--- Comment #4 from Vittorio <zeccav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> ---
Also in matrix.c:1156 the line
"#define ONE(x) (1 <<(x+16))"
should be
"#define ONE(x) (1U<<(x+16))"
because ONE(15) later, as at line 1226, produces 16 bits left shift of 65536,
which is bigger than int.
This is running teapot.
--
You are receiving this mail because:
You are the assignee for the bug.
[-- Attachment #1.2: Type: text/html, Size: 1309 bytes --]
[-- Attachment #2: Type: text/plain, Size: 181 bytes --]
_______________________________________________
Nouveau mailing list
Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 11+ messages in thread* [Bug 80266] Undefined operation in tgsi_ureg.c left shift of 1 by 31 places cannot be represented in type 'int'
[not found] ` <bug-80266-8800-V0hAGp6uBxMKqLRl/0Ahz6D7qz1kEfGD2LY78lusg7I@public.gmane.org/>
` (3 preceding siblings ...)
2014-06-20 18:12 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
@ 2014-06-20 18:18 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
2014-06-20 18:45 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ @ 2014-06-20 18:18 UTC (permalink / raw)
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
[-- Attachment #1.1: Type: text/plain, Size: 410 bytes --]
https://bugs.freedesktop.org/show_bug.cgi?id=80266
--- Comment #5 from Ilia Mirkin <imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org> ---
I'm not sure why you're filing these against nouveau... I'm sure there are
_tons_ of these throughout mesa...
Does gcc warn about this? Are you _sure_ that (signed int)1 << 31 is illegal in
C99?
--
You are receiving this mail because:
You are the assignee for the bug.
[-- Attachment #1.2: Type: text/html, Size: 1262 bytes --]
[-- Attachment #2: Type: text/plain, Size: 181 bytes --]
_______________________________________________
Nouveau mailing list
Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 11+ messages in thread* [Bug 80266] Undefined operation in tgsi_ureg.c left shift of 1 by 31 places cannot be represented in type 'int'
[not found] ` <bug-80266-8800-V0hAGp6uBxMKqLRl/0Ahz6D7qz1kEfGD2LY78lusg7I@public.gmane.org/>
` (4 preceding siblings ...)
2014-06-20 18:18 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
@ 2014-06-20 18:45 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
2014-06-20 19:03 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ @ 2014-06-20 18:45 UTC (permalink / raw)
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
[-- Attachment #1.1: Type: text/plain, Size: 1200 bytes --]
https://bugs.freedesktop.org/show_bug.cgi?id=80266
--- Comment #6 from Patrick Baggett <baggett.patrick-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> ---
I'm sure that technically shifting any bits into the sign bit of a signed
number produces undefined behavior according to C99, so yes, (1<<31)
technically is undefined. As a matter of practicality, on basically any CPU,
1<<31 will produce a valid negative number, but the compiler sees it as trying
to assign the constant 2147483648 to a 32-bit signed container, which is
outside of the 2^31-1 range that it can accept.
In the C abstract machine, this would be a serious problem. Obviously you can
make such an assignment in hardware, but the result (when interpreted as
signed) is not a value of 2147483648, but a value of -2147483648, which is why
the compiler gives a warning. It's weird to read that (1<<31) is less than 0.
If you don't really mean to assign a value of -2147483648 or 2147483648 and
just want a bit pattern, using unsigned is almost always the way to go.
I know that Solaris Studio happens to give a warning for the same case, if that
means anything.
--
You are receiving this mail because:
You are the assignee for the bug.
[-- Attachment #1.2: Type: text/html, Size: 2070 bytes --]
[-- Attachment #2: Type: text/plain, Size: 181 bytes --]
_______________________________________________
Nouveau mailing list
Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 11+ messages in thread* [Bug 80266] Undefined operation in tgsi_ureg.c left shift of 1 by 31 places cannot be represented in type 'int'
[not found] ` <bug-80266-8800-V0hAGp6uBxMKqLRl/0Ahz6D7qz1kEfGD2LY78lusg7I@public.gmane.org/>
` (5 preceding siblings ...)
2014-06-20 18:45 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
@ 2014-06-20 19:03 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
2014-06-20 19:12 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ @ 2014-06-20 19:03 UTC (permalink / raw)
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
[-- Attachment #1.1: Type: text/plain, Size: 370 bytes --]
https://bugs.freedesktop.org/show_bug.cgi?id=80266
--- Comment #7 from Vittorio <zeccav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> ---
In m_matrix.c:1215
" if (m[15] == 1.0F) mask |= (1<<31);"
should be
" if (m[15] == 1.0F) mask |= (1U<<31);"
because 1<<31 does not fit in int.
From teapot.
--
You are receiving this mail because:
You are the assignee for the bug.
[-- Attachment #1.2: Type: text/html, Size: 1244 bytes --]
[-- Attachment #2: Type: text/plain, Size: 181 bytes --]
_______________________________________________
Nouveau mailing list
Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 11+ messages in thread* [Bug 80266] Undefined operation in tgsi_ureg.c left shift of 1 by 31 places cannot be represented in type 'int'
[not found] ` <bug-80266-8800-V0hAGp6uBxMKqLRl/0Ahz6D7qz1kEfGD2LY78lusg7I@public.gmane.org/>
` (6 preceding siblings ...)
2014-06-20 19:03 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
@ 2014-06-20 19:12 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
2014-06-20 19:16 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
2014-06-20 19:17 ` [Bug 80266] Many instances of 1<<31, which is undefined in C99 bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
9 siblings, 0 replies; 11+ messages in thread
From: bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ @ 2014-06-20 19:12 UTC (permalink / raw)
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
[-- Attachment #1.1: Type: text/plain, Size: 737 bytes --]
https://bugs.freedesktop.org/show_bug.cgi?id=80266
--- Comment #8 from Vittorio <zeccav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> ---
(In reply to comment #5)
> I'm not sure why you're filing these against nouveau... I'm sure there are
> _tons_ of these throughout mesa...
>
> Does gcc warn about this? Are you _sure_ that (signed int)1 << 31 is illegal
> in C99?
Only now I am reading this note.
I compiled mesa with gcc -fsanitize=undefined option, gcc runtime is issuing
several, not tons, of runtime error messages, it seems to me that
(signed int) 1 << 31 is undefined if computed as int.
The runtime error messages only appear with the -std=c99 option.
--
You are receiving this mail because:
You are the assignee for the bug.
[-- Attachment #1.2: Type: text/html, Size: 1667 bytes --]
[-- Attachment #2: Type: text/plain, Size: 181 bytes --]
_______________________________________________
Nouveau mailing list
Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 11+ messages in thread* [Bug 80266] Undefined operation in tgsi_ureg.c left shift of 1 by 31 places cannot be represented in type 'int'
[not found] ` <bug-80266-8800-V0hAGp6uBxMKqLRl/0Ahz6D7qz1kEfGD2LY78lusg7I@public.gmane.org/>
` (7 preceding siblings ...)
2014-06-20 19:12 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
@ 2014-06-20 19:16 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
2014-06-20 19:17 ` [Bug 80266] Many instances of 1<<31, which is undefined in C99 bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
9 siblings, 0 replies; 11+ messages in thread
From: bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ @ 2014-06-20 19:16 UTC (permalink / raw)
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
[-- Attachment #1.1: Type: text/plain, Size: 1395 bytes --]
https://bugs.freedesktop.org/show_bug.cgi?id=80266
--- Comment #9 from Vittorio <zeccav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> ---
(In reply to comment #6)
> I'm sure that technically shifting any bits into the sign bit of a signed
> number produces undefined behavior according to C99, so yes, (1<<31)
> technically is undefined. As a matter of practicality, on basically any CPU,
> 1<<31 will produce a valid negative number, but the compiler sees it as
> trying to assign the constant 2147483648 to a 32-bit signed container, which
> is outside of the 2^31-1 range that it can accept.
>
> In the C abstract machine, this would be a serious problem. Obviously you
> can make such an assignment in hardware, but the result (when interpreted as
> signed) is not a value of 2147483648, but a value of -2147483648, which is
> why the compiler gives a warning. It's weird to read that (1<<31) is less
> than 0. If you don't really mean to assign a value of -2147483648 or
> 2147483648 and just want a bit pattern, using unsigned is almost always the
> way to go.
>
> I know that Solaris Studio happens to give a warning for the same case, if
> that means anything.
Thanks for the appreciated explanation.
Maybe substituting 1<<31 with 1U<<31 clears any undefined behaviour on the many
architectures where mesa runs.
--
You are receiving this mail because:
You are the assignee for the bug.
[-- Attachment #1.2: Type: text/html, Size: 2379 bytes --]
[-- Attachment #2: Type: text/plain, Size: 181 bytes --]
_______________________________________________
Nouveau mailing list
Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 11+ messages in thread* [Bug 80266] Many instances of 1<<31, which is undefined in C99
[not found] ` <bug-80266-8800-V0hAGp6uBxMKqLRl/0Ahz6D7qz1kEfGD2LY78lusg7I@public.gmane.org/>
` (8 preceding siblings ...)
2014-06-20 19:16 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
@ 2014-06-20 19:17 ` bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ
9 siblings, 0 replies; 11+ messages in thread
From: bugzilla-daemon-CC+yJ3UmIYqDUpFQwHEjaQ @ 2014-06-20 19:17 UTC (permalink / raw)
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
[-- Attachment #1.1: Type: text/plain, Size: 831 bytes --]
https://bugs.freedesktop.org/show_bug.cgi?id=80266
Ilia Mirkin <imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|nouveau-PD4FTy7X32lNgt0PjOBp93rCq3LdnpKM@public.gmane.org |mesa-dev-PD4FTy7X32lNgt0PjOBp9/rsn8yoX9R0@public.gmane.org
|rg |org
Summary|Undefined operation in |Many instances of 1<<31,
|tgsi_ureg.c left shift of 1 |which is undefined in C99
|by 31 places cannot be |
|represented in type 'int' |
Component|Drivers/DRI/nouveau |Mesa core
--
You are receiving this mail because:
You are the assignee for the bug.
[-- Attachment #1.2: Type: text/html, Size: 1586 bytes --]
[-- Attachment #2: Type: text/plain, Size: 181 bytes --]
_______________________________________________
Nouveau mailing list
Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 11+ messages in thread