classification
Title: audioop.c giving signed/unsigned warnings on Windows
Type: compile error Stage: resolved
Components: Build Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: python-dev, serhiy.storchaka, tim.golden, tim.peters, vstinner
Priority: normal Keywords: patch

Created on 2013-10-27 19:44 by tim.golden, last changed 2018-06-06 15:51 by vstinner. This issue is now closed.

Files
File name Uploaded Description Edit
issue19418.2.diff tim.golden, 2013-10-28 20:49 review
Pull Requests
URL Status Linked Edit
PR 7453 merged vstinner, 2018-06-06 15:17
Messages (17)
msg201485 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2013-10-27 19:44
Modules/audioop.c is giving compile warnings on Windows against lines 18 & 437.

..\Modules\audioop.c(18): warning C4146: unary minus operator applied to unsigned type, result still unsigned
..\Modules\audioop.c(437): warning C4146: unary minus operator applied to unsigned type, result still unsigned
msg201486 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2013-10-27 19:46
The attached patch appears to fix the problem.
msg201490 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-10-27 20:16
But it adds warnings on 32-bit platform with GCC.

/home/serhiy/py/cpython/Modules/audioop.c:18:61: warning: integer overflow in expression [-Woverflow]
/home/serhiy/py/cpython/Modules/audioop.c: In function ‘audioop_minmax’:
/home/serhiy/py/cpython/Modules/audioop.c:437:33: warning: integer overflow in expression [-Woverflow]
msg201491 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-10-27 20:19
What if use (int)-0x80000000 instead of -(int)0x80000000? Does it silence warnings on Windows?
msg201492 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2013-10-27 20:20
I don't think it will, given MS description of the compiler warning:

http://msdn.microsoft.com/en-us/library/4kh09110%28v=vs.100%29.aspx

but I'll certainly give it a go.
msg201495 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2013-10-27 20:42
Use

-0x7FFFFFFF-1

Nobody should complain about that, because it's standard C ;-)

On Sun, Oct 27, 2013 at 3:20 PM, Tim Golden <report@bugs.python.org> wrote:
>
> Tim Golden added the comment:
>
> I don't think it will, given MS description of the compiler warning:
>
> http://msdn.microsoft.com/en-us/library/4kh09110%28v=vs.100%29.aspx
>
> but I'll certainly give it a go.
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue19418>
> _______________________________________
> _______________________________________________
> Python-bugs-list mailing list
> Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/tim.peters%40gmail.com
>
msg201496 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-10-27 20:46
LGTM. Do you want commit a patch?
msg201499 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2013-10-27 20:58
@Serhiy, nope, pressed for time today :-(
msg201501 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2013-10-27 21:05
Good idea. I'll test against Win32/64 & Linux 32
msg201575 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2013-10-28 20:31
The attached patch (using Tim Peters' -1 trick) builds & tests ok on Win32/64 & Linux 32.
msg201576 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-10-28 20:37
You should add a comment to explain why the trick is required (because of compilers not supporting -0x80000000 literal without a warning).
msg201579 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2013-10-28 20:49
Good point. Updated patch.
msg201584 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-10-28 21:21
LGTM.
msg201798 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-31 10:52
New changeset 0848c90a5dd1 by Tim Golden in branch 'default':
Issue #19418 Fix some warnings on Win64
http://hg.python.org/cpython/rev/0848c90a5dd1
msg201833 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-31 17:40
New changeset 54bf7b5ec3b6 by Tim Golden in branch '3.3':
Issue #19418 Fix some warnings on Win64
http://hg.python.org/cpython/rev/54bf7b5ec3b6
msg201835 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2013-10-31 17:51
Fixed in 3.3 / 3.4
msg318836 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-06 15:51
New changeset e5b79c546370521764457ea2ec809303e580f5ea by Victor Stinner in branch '2.7':
bpo-19418: audioop.c: Fix warnings on -0x80000000 (GH-7453)
https://github.com/python/cpython/commit/e5b79c546370521764457ea2ec809303e580f5ea
History
Date User Action Args
2018-06-06 15:51:10vstinnersetmessages: + msg318836
2018-06-06 15:17:48vstinnersetpull_requests: + pull_request7075
2013-10-31 17:51:52tim.goldensetstatus: open -> closed
versions: - Python 2.7
messages: + msg201835

resolution: fixed
stage: commit review -> resolved
2013-10-31 17:40:56python-devsetmessages: + msg201833
2013-10-31 10:52:07python-devsetnosy: + python-dev
messages: + msg201798
2013-10-28 21:21:53serhiy.storchakasetmessages: + msg201584
2013-10-28 20:50:22tim.goldensetfiles: - issue19418.diff
2013-10-28 20:49:56tim.goldensetfiles: + issue19418.2.diff

messages: + msg201579
2013-10-28 20:37:00vstinnersetnosy: + vstinner
messages: + msg201576
2013-10-28 20:31:26tim.goldensetfiles: - audioop.diff
2013-10-28 20:31:16tim.goldensetfiles: + issue19418.diff

messages: + msg201575
2013-10-27 21:05:23tim.goldensetmessages: + msg201501
2013-10-27 20:58:17tim.peterssetmessages: + msg201499
2013-10-27 20:46:32serhiy.storchakasetstage: commit review
messages: + msg201496
versions: + Python 2.7, Python 3.3
2013-10-27 20:42:25tim.peterssetnosy: + tim.peters
messages: + msg201495
2013-10-27 20:20:49tim.goldensetmessages: + msg201492
2013-10-27 20:19:10serhiy.storchakasetmessages: + msg201491
2013-10-27 20:16:38serhiy.storchakasetmessages: + msg201490
2013-10-27 19:46:05tim.goldensetfiles: + audioop.diff
keywords: + patch
messages: + msg201486
2013-10-27 19:44:37tim.goldencreate