Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation warnings under x64 Windows #53775

Closed
pitrou opened this issue Aug 10, 2010 · 68 comments
Closed

Compilation warnings under x64 Windows #53775

pitrou opened this issue Aug 10, 2010 · 68 comments
Labels
3.7 (EOL) end of life extension-modules C modules in the Modules dir interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@pitrou
Copy link
Member

pitrou commented Aug 10, 2010

BPO 9566
Nosy @loewis, @terryjreedy, @amauryfa, @pitrou, @vstinner, @jkloth, @florentx, @zooba, @segevfiner
PRs
  • bpo-9566: Fix some Windows x64 compiler warnings #2492
  • bpo-9566: Fixed _ssl module warnings #2495
  • bpo-9566: Silence warning in gcmodule.c caused by pydtrace.h #2852
  • bpo-9566: Silence a warning in Python/getargs.c (Windows x64) #2890
  • bpo-9566: Change HANDLE argument parsing to unsigned in msvcrtmodule.c #2904
  • bpo-9566 & bpo-30747: Silence warnings from pyatomic.h macros #3140
  • bpo-9566: Fix size_t=>int downcast warnings #5230
  • bpo-9566: Fix compiler warnings in peephole.c #10652
  • bpo-9566: Fix compiler warnings in pyexpat.c #10654
  • bpo-32805: Fix compiler warnings in gcmodule.c #11010
  • bpo-9566: Fix compiler warnings in peephole.c #11011
  • [3.7] bpo-9566: Fix compiler warnings on Windows #12920
  • Files
  • socketmodule_int.patch
  • ssl_sock_fd_int.patch
  • ssl_write.patch
  • hash.patch
  • _sre.patch
  • issue9566.patch
  • warnings64.log
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-03-06.16:59:45.090>
    created_at = <Date 2010-08-10.23:59:44.889>
    labels = ['extension-modules', 'interpreter-core', 'type-bug', '3.7']
    title = 'Compilation warnings under x64 Windows'
    updated_at = <Date 2019-04-23.08:26:14.583>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2019-04-23.08:26:14.583>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-03-06.16:59:45.090>
    closer = 'vstinner'
    components = ['Extension Modules', 'Interpreter Core']
    creation = <Date 2010-08-10.23:59:44.889>
    creator = 'pitrou'
    dependencies = []
    files = ['20345', '20346', '20347', '20348', '20349', '20350', '26465']
    hgrepos = []
    issue_num = 9566
    keywords = ['patch', 'buildbot']
    message_count = 68.0
    messages = ['113573', '113574', '113975', '113977', '113978', '113983', '113987', '125311', '125334', '125363', '125367', '125370', '125371', '125377', '125384', '125385', '125390', '125951', '125963', '125969', '125970', '125971', '125972', '125973', '125974', '140000', '166018', '174246', '189421', '189427', '190619', '190621', '190622', '190630', '191801', '191803', '191804', '191810', '191811', '191813', '191814', '191815', '203267', '203424', '203428', '203434', '203442', '222031', '222035', '251557', '297298', '299249', '299267', '299268', '299275', '299276', '299277', '299289', '299329', '300610', '310230', '330250', '330251', '331261', '331338', '337327', '337328', '340700']
    nosy_count = 12.0
    nosy_names = ['loewis', 'terry.reedy', 'amaury.forgeotdarc', 'pitrou', 'vstinner', 'schmir', 'jkloth', 'janglin', 'flox', 'python-dev', 'steve.dower', 'Segev Finer']
    pr_nums = ['2492', '2495', '2852', '2890', '2904', '3140', '5230', '10652', '10654', '11010', '11011', '12920']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue9566'
    versions = ['Python 3.5', 'Python 3.6', 'Python 3.7']

    @pitrou
    Copy link
    Member Author

    pitrou commented Aug 10, 2010

    A 64-bit build under Windows produces many compilation warnings, mostly related to lossy conversions between different int sizes.
    Some of these warnings appear harmless after analysis (are MS 64 bit compilers pickier than their 32 bit counterparts?).
    It would probably be spammy to open a separate issue per file.

    5>..\Python\pythonrun.c(1210) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data

    5>..\Python\Python-ast.c(3403) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(3409) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(3439) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(3445) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(3498) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(3504) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(3608) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(3614) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(3633) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(3639) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(3699) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(3705) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(3724) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(3730) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(3771) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(3777) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(3796) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(3802) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(3855) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(3861) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(3892) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(3898) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4016) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4022) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4041) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4047) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4092) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4098) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4117) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4123) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4167) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4173) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4192) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4198) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4253) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4259) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4326) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4332) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4351) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4357) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4376) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4382) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4414) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4420) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4439) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4445) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4510) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4516) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4559) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4565) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4607) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4613) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4643) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4649) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4791) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4797) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(4998) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5004) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5023) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5029) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5059) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5065) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5108) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5114) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5157) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5163) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5219) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5225) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5269) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5275) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5341) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5347) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5366) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5372) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5419) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5425) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5444) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5450) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5753) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5759) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5802) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5808) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5979) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(5985) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(6356) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(6362) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(6456) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(6462) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(6508) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(6514) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(6555) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(6561) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(6602) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(6608) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(6627) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\Python-ast.c(6633) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data

    5>..\Python\dtoa.c(1529) : warning C4244: '=' : conversion from '__int64' to 'int', possible loss of data
    5>..\Python\dtoa.c(1539) : warning C4244: '-=' : conversion from '__int64' to 'int', possible loss of data
    5>..\Python\dtoa.c(1545) : warning C4244: '+=' : conversion from '__int64' to 'int', possible loss of data

    5>..\Python\pystrtod.c(902) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\pystrtod.c(1023) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data

    5>..\Python\peephole.c(84) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'unsigned char', possible loss of data
    5>..\Python\peephole.c(184) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'unsigned char', possible loss of data
    5>..\Python\peephole.c(237) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'unsigned char', possible loss of data
    5>..\Python\peephole.c(309) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'unsigned char', possible loss of data
    5>..\Python\peephole.c(352) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\peephole.c(403) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'unsigned char', possible loss of data
    5>..\Python\peephole.c(418) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'unsigned char', possible loss of data
    5>..\Python\peephole.c(459) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\peephole.c(544) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\peephole.c(555) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'unsigned char', possible loss of data
    5>..\Python\peephole.c(587) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\peephole.c(601) : warning C4244: '-=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\peephole.c(632) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\peephole.c(661) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'unsigned char', possible loss of data
    5>..\Python\peephole.c(671) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'unsigned char', possible loss of data

    5>..\Python\getargs.c(390) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\getargs.c(502) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\getargs.c(876) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\getargs.c(931) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\getargs.c(939) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\getargs.c(983) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\getargs.c(1133) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\getargs.c(1476) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\getargs.c(1477) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data

    5>z:\py3k\svn\python\../Objects/stringlib/formatter.h(984) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>z:\py3k\svn\python\../Objects/stringlib/formatter.h(1161) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>z:\py3k\svn\python\../Objects/stringlib/formatter.h(1165) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data

    5>..\Python\compile.c(339) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'long', possible loss of data
    5>..\Python\compile.c(384) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'long', possible loss of data
    5>..\Python\compile.c(479) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\compile.c(533) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\compile.c(947) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'long', possible loss of data
    5>..\Python\compile.c(962) : warning C4244: 'return' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\compile.c(1254) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\compile.c(1399) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\compile.c(3678) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\compile.c(3704) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\compile.c(3730) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\compile.c(3898) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\compile.c(3902) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\compile.c(3942) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\compile.c(3949) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data

    5>..\Python\ceval.c(3967) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Python\ceval.c(4155) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data

    5>..\PC\winreg.c(769) : warning C4267: '=' : conversion from 'size_t' to 'DWORD', possible loss of data
    5>..\PC\winreg.c(801) : warning C4267: '+=' : conversion from 'size_t' to 'DWORD', possible loss of data
    5>..\PC\winreg.c(851) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'DWORD', possible loss of data
    5>..\PC\winreg.c(1186) : warning C4133: '=' : incompatible types - from 'wchar_t *' to 'BYTE *'

    5>..\PC\_subprocess.c(345) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\PC\_subprocess.c(368) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\PC\_subprocess.c(369) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\PC\_subprocess.c(371) : warning C4244: '=' : conversion from '__int64' to 'int', possible loss of data
    5>..\PC\_subprocess.c(373) : warning C4244: 'initializing' : conversion from '__int64' to 'int', possible loss of data

    5>..\Parser\tokenizer.c(658) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
    5>..\Parser\tokenizer.c(689) : warning C4244: '=' : conversion from '__int64' to 'int', possible loss of data

    5>..\Parser\parsetok.c(199) : warning C4244: '=' : conversion from '__int64' to 'int', possible loss of data

    5>..\Parser\grammar.c(66) : warning C4244: 'return' : conversion from '__int64' to 'int', possible loss of data
    5>..\Parser\grammar.c(108) : warning C4244: 'return' : conversion from '__int64' to 'int', possible loss of data

    5>..\Objects\typeobject.c(6173) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data

    5>..\Objects\setobject.c(743) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'long', possible loss of data
    5>..\Objects\setobject.c(772) : warning C4244: '*=' : conversion from 'Py_ssize_t' to 'long', possible loss of data
    5>..\Objects\setobject.c(819) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'long', possible loss of data

    5>..\Objects\obmalloc.c(904) : warning C4244: '=' : conversion from '__int64' to 'unsigned int', possible loss of data

    5>..\Objects\funcobject.c(633) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Objects\funcobject.c(634) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Objects\funcobject.c(634) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data

    5>..\Objects\frameobject.c(480) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Objects\frameobject.c(513) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Objects\frameobject.c(871) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Objects\frameobject.c(872) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Objects\frameobject.c(918) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Objects\frameobject.c(919) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data

    5>..\Objects\fileobject.c(401) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'unsigned int', possible loss of data

    5>..\Objects\descrobject.c(891) : warning C4244: '=' : conversion from '__int64' to 'int', possible loss of data

    5>..\Objects\codeobject.c(495) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Objects\codeobject.c(517) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data

    5>..\Objects\bytesobject.c(786) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Objects\bytesobject.c(795) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Objects\bytesobject.c(1755) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Objects\bytesobject.c(1947) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Objects\bytesobject.c(2620) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'char', possible loss of data
    5>..\Objects\bytesobject.c(2641) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'char', possible loss of data
    5>..\Objects\bytesobject.c(2696) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'char', possible loss of data

    5>..\Objects\bytearrayobject.c(1222) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Objects\bytearrayobject.c(1231) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data

    5>..\Objects\bytes_methods.c(454) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'char', possible loss of data

    5>..\Modules\_io\fileio.c(483) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'unsigned int', possible loss of data
    5>..\Modules\_io\fileio.c(566) : warning C4267: 'function' : conversion from 'size_t' to 'unsigned int', possible loss of data
    5>..\Modules\_io\fileio.c(622) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'unsigned int', possible loss of data
    5>..\Modules\_io\fileio.c(662) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'unsigned int', possible loss of data

    5>..\Modules\zlibmodule.c(127) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\zlibmodule.c(211) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\zlibmodule.c(217) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'uInt', possible loss of data
    5>..\Modules\zlibmodule.c(271) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'uInt', possible loss of data
    5>..\Modules\zlibmodule.c(422) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\zlibmodule.c(434) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'uInt', possible loss of data
    5>..\Modules\zlibmodule.c(451) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'uInt', possible loss of data
    5>..\Modules\zlibmodule.c(505) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\zlibmodule.c(526) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'uInt', possible loss of data
    5>..\Modules\zlibmodule.c(556) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'uInt', possible loss of data
    5>..\Modules\zlibmodule.c(935) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'uInt', possible loss of data
    5>..\Modules\zlibmodule.c(938) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'uInt', possible loss of data
    5>..\Modules\zlibmodule.c(963) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'uInt', possible loss of data
    5>..\Modules\zlibmodule.c(966) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'uInt', possible loss of data

    5>..\Modules\sha512module.c(558) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\sha512module.c(710) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\sha512module.c(751) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data

    5>..\Modules\sha256module.c(492) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\sha256module.c(644) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\sha256module.c(685) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data

    5>..\Modules\sha1module.c(399) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'unsigned long', possible loss of data
    5>..\Modules\sha1module.c(520) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'unsigned long', possible loss of data

    5>..\Modules\posixmodule.c(394) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
    5>..\Modules\posixmodule.c(3708) : warning C4133: 'function' : incompatible types - from 'int *' to 'Py_ssize_t *'
    5>..\Modules\posixmodule.c(4886) : warning C4244: 'function' : conversion from 'Py_intptr_t' to 'long', possible loss of data
    5>..\Modules\posixmodule.c(5593) : warning C4267: 'function' : conversion from 'size_t' to 'unsigned int', possible loss of data

    5>..\Modules\mmapmodule.c(881) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'char', possible loss of data

    5>..\Modules\md5module.c(423) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'unsigned long', possible loss of data
    5>..\Modules\md5module.c(544) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'unsigned long', possible loss of data

    5>..\Modules\binascii.c(667) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'unsigned char', possible loss of data

    5>..\Modules\audioop.c(332) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\audioop.c(354) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\audioop.c(376) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\audioop.c(398) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\audioop.c(423) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\audioop.c(632) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\audioop.c(687) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\audioop.c(737) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\audioop.c(763) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\audioop.c(810) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\audioop.c(868) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\audioop.c(928) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\audioop.c(984) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\audioop.c(1018) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\audioop.c(1053) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\audioop.c(1284) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\audioop.c(1316) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\audioop.c(1353) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\audioop.c(1385) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\audioop.c(1424) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\audioop.c(1530) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data

    5>z:\py3k\svn\modules\_sre.c(1898) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>z:\py3k\svn\modules\_sre.c(1901) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>z:\py3k\svn\modules\_sre.c(1935) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>z:\py3k\svn\modules\_sre.c(1938) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>z:\py3k\svn\modules\_sre.c(2082) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>z:\py3k\svn\modules\_sre.c(2085) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>z:\py3k\svn\modules\_sre.c(2212) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>z:\py3k\svn\modules\_sre.c(2215) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>z:\py3k\svn\modules\_sre.c(2364) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>z:\py3k\svn\modules\_sre.c(2367) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>z:\py3k\svn\modules\_sre.c(3753) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>z:\py3k\svn\modules\_sre.c(3756) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>z:\py3k\svn\modules\_sre.c(3786) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>z:\py3k\svn\modules\_sre.c(3789) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data

    5>..\Modules\_pickle.c(284) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\_pickle.c(301) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\_pickle.c(461) : warning C4244: '+=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\_pickle.c(628) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'long', possible loss of data
    5>..\Modules\_pickle.c(647) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
    5>..\Modules\_pickle.c(1320) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\_pickle.c(1558) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\_pickle.c(1806) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data

    5>..\Modules\_csv.c(971) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\_csv.c(1100) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\_csv.c(1105) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    5>..\Modules\_csv.c(1133) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data

    5>..\Modules\_collectionsmodule.c(1124) : warning C4244: 'function' :
    conversion from 'Py_ssize_t' to 'long', possible loss of data

    @pitrou pitrou added extension-modules C modules in the Modules dir interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Aug 10, 2010
    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Aug 11, 2010

    This must be a duplicate report - this issue has been known for years, and Kristjan and others (including myself) volunteered to work on it, and did actually work on it.

    I don't think it's necessary to have a bug report in the bug tracker for it. If you find a place that you would like to fix, just go ahead and fix it.

    Please keep in mind the following principles:

    • if a value can reasonably overflow an int, change the data type to something larger (typically Py_ssize_t)
    • if the value can overflow in principle, but likely won't, and it is difficult to fix the data type (e.g. because it's at a system interface), make a range check, raise a Python exception, and then SAFECAST the value.
    • if the value "shouldn't" overflow (i.e. you are believe from the data flow or other invariants that it can't happen), use a safecast
    • if you are certain that the value can't overflow (e.g. if you are converting the result of a sizeof of some structure), use a regular cast, along with a comment

    This leaves us with a number of cases where there are pragmatic Python limitations (such as the data type for line numbers, or the number of values when building a tuple in source) which make it impossible to get overflows in the current implementation. Such limitations should be collected in some place, and then SAFECASTs should be added, along with asserts at startup (e.g. that a certain datatype has no more than 2 bytes).

    @pitrou
    Copy link
    Member Author

    pitrou commented Aug 15, 2010

    Created bpo-9611 to report the FileIO 64-bit issue under Windows.

    @pitrou
    Copy link
    Member Author

    pitrou commented Aug 15, 2010

    Created bpo-9612 for the mostly harmless warnings in the set implementation.

    @pitrou
    Copy link
    Member Author

    pitrou commented Aug 15, 2010

    The zlib warnings are genuine and there's a specific bug for 64-bitness of zlibmodule.c: bpo-8650.

    @pitrou
    Copy link
    Member Author

    pitrou commented Aug 15, 2010

    Opened bpo-9613 for 64-bitness of process ids.

    @pitrou
    Copy link
    Member Author

    pitrou commented Aug 15, 2010

    Opened bpo-9614 for the _pickle issues (which look quite legitimate).

    @vstinner
    Copy link
    Member

    vstinner commented Jan 4, 2011

    r87733 fixes some conversions in:

    For md5, sha1, sha256 and sha512: a smaller type (int) can be used for the local n variable. I don't know if it impacts performances or not. md5 and sha1 used "unsigned long", sha256 and sha512 used "int".

    @amauryfa
    Copy link
    Member

    amauryfa commented Jan 4, 2011

    r87733 in pyexpat.c modified a call to PyErr_Format with a %zi format code.
    This format does not seem to be supported. %zd should be used instead.

    @vstinner
    Copy link
    Member

    vstinner commented Jan 4, 2011

    bpo-10823 has been marked as a duplicate of this issue.

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Jan 4, 2011

    haypo: please avoid introducing explicit casts (such as the one in pyexpat.c). Use SAFECASTs instead. If you are absolutely certain that a cast cannot possibly truncate, add a comment explaining why that is. In the specific case, I think it actually *is* possible that the cast truncates, because the case that read() returned too many bytes is incorrectly handled (it should set len to -1).

    @vstinner
    Copy link
    Member

    vstinner commented Jan 4, 2011

    amaury> r87733 in pyexpat.c modified a call to PyErr_Format with a %zi
    amaury> format code. This format does not seem to be supported. %zd
    amaury> should be used instead.

    Oh, that's surprising. Why %zd is supported but not %zi?

    PyUnicode_FromFormatV() supports %d, %ld, %lld, %zd, %i, but not %li, %lli or %zi. Before fixing PyUnicode_FromFormatV(), I fixed pyexpat.c: r87747.

    MvL> If you are absolutely certain that a cast cannot possibly truncate,
    MvL> add a comment explaining why that is.

    Ah yes, sorry, I forgot to add a comment: done in r87746.

    @vstinner
    Copy link
    Member

    vstinner commented Jan 4, 2011

    Python\pystrtod.c(902) : 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data
    Python\pystrtod.c(1023) : '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data

    I asked dmalcolm on IRC if int or Py_ssize_t should be used:

    "this is the number of digits to use in the floating point representation, right? it strikes me that if you're overflowing an int, you're asking for a very very very long string" (yes, INT_MAX is usually 2^31)

    "... looking at usage of precision seems to ultimately land in Python/dtoa.c, which uses int..."

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Jan 4, 2011

    MvL> If you are absolutely certain that a cast cannot possibly truncate,
    MvL> add a comment explaining why that is.

    Ah yes, sorry, I forgot to add a comment: done in r87746.

    But the comment is actually wrong: It says

    len <= buf_size <= INT_MAX (see above)

    however, len > buf_size may happen, after this code:

        if (len > buf_size) {
            PyErr_Format(PyExc_ValueError,
                         "read() returned too much data: "
                         "%i bytes requested, %zd returned",
                         buf_size, len);
            goto finally;
        }

    @vstinner
    Copy link
    Member

    vstinner commented Jan 4, 2011

    But the comment is actually wrong: It says

    len <= buf_size <= INT_MAX (see above)

    however, len > buf_size may happen, after this code:

    if (len \> buf_size) {
        PyErr_Format(PyExc_ValueError,
                     "read() returned too much data: "
                     "%i bytes requested, %zd returned",
                     buf_size, len);
        goto finally;
    }
    

    Oh. Not only is the comment is wrong, but the code is also wrong. It
    should return a negative value on error, whereas it returns the string
    length which is always positive (except on a unlikely Py_ssize_t => int
    overflow?).

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Jan 5, 2011

    Oh. Not only is the comment is wrong, but the code is also wrong. It
    should return a negative value on error, whereas it returns the string
    length which is always positive (except on a unlikely Py_ssize_t => int
    overflow?).

    Right. See msg125367.

    @vstinner
    Copy link
    Member

    vstinner commented Jan 5, 2011

    pyexpat.patch: new try, does it look better?

    @vstinner
    Copy link
    Member

    [readinst) should return a negative value on error, whereas it
    returns the string length which is always positive

    Fixed by r87911.

    @vstinner
    Copy link
    Member

    socketmodule_int.patch: Fix similar to the fix for bpo-9611: clamp length to INT_MAX on Windows for recv(), recvfrom(), send() and sendto().

    @vstinner
    Copy link
    Member

    ssl_sock_fd_int.patch: add SOCKET_T_AS_INT(fd) macro to cast a socket descriptor (SOCKET_T) to int. I choosed a macro just to not have to repeat a comment twice :-)

    It looks like it is a safe to cast SOCKET_T to int. My comment:

    /* On Windows, SOCKET_T is an offset in per-process handle table.
    The per-process limit on kernel handles is 2^24. Kernel Objects:
    http://msdn.microsoft.com/en-us/library/ms724485%28VS.85%29.aspx
    */

    @vstinner
    Copy link
    Member

    On Windows, SOCKET_T is an offset in per-process handle table.
    The per-process limit on kernel handles is 2^24. Kernel Objects:

    Reference: http://www.mail-archive.com/openssl-dev@openssl.org/msg23781.html

    @vstinner
    Copy link
    Member

    ssl_write.patch: always clamp SSL_Write() size to INT_MAX. This patch fixes also an overflow if Py_ssize_t is 32 bits (if the size is bigger than INT_MAX).

    @vstinner
    Copy link
    Member

    hash.patch: continue my fix on md5, sha1, sha256, sha512.

    @vstinner
    Copy link
    Member

    _sre.patch: store sre_match() result in Py_ssize_t instead of int.

    @vstinner
    Copy link
    Member

    ... and bpo-9566.patch: various fixes. Interesting parts:

    ---

    • id = PyLong_FromLong((Py_uintptr_t) self);
      + id = PyLong_FromVoidPtr(self);
      ---

    ---

     LOCAL(PyObject*)
    -expat_parse(XMLParserObject* self, char* data, int data_len, int final)
    +expat_parse(XMLParserObject* self, char* data, Py_ssize_t data_len, int final)
     {
         int ok;
     
    -    ok = EXPAT(Parse)(self->parser, data, data_len, final);
    +    if (data_len > INT_MAX) {
    +        PyErr_SetString(PyExc_OverflowError, "length doesn't fit in an int");
    +        return NULL;
    +    }
    +
    +    ok = EXPAT(Parse)(self->parser, data, (int)data_len, final);
    ---
    
    

    •    long hash = PyObject_Hash(arg);
      

    + Py_hash_t hash = PyObject_Hash(arg);
    ---

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jul 7, 2011

    New changeset 43fd627cc060 by Victor Stinner in branch 'default':
    Issue bpo-9566: cast unsigned int to Py_ssize_t in md5 and sha1 modules
    http://hg.python.org/cpython/rev/43fd627cc060

    @florentx
    Copy link
    Mannequin

    florentx mannequin commented Jul 21, 2012

    Attached file is a copy of the remaining warnings on the AMD64 Windows7 SP1 3.x builder.

    @vstinner
    Copy link
    Member

    I forgot to mention this issue in the following changesets.

    changeset: 87128:f0a7924fac56
    user: Victor Stinner <victor.stinner@gmail.com>
    date: Fri Nov 15 23:16:15 2013 +0100
    files: Modules/_randommodule.c
    description:
    Fix compiler warning on Windows 64-bit: explicit cast size_t to unsigned long

    changeset: 87129:8adbd8a3a626
    user: Victor Stinner <victor.stinner@gmail.com>
    date: Fri Nov 15 23:21:11 2013 +0100
    files: Modules/_sre.c
    description:
    Fix compiler warning (especially on Windows 64-bit): don't truncate Py_ssize_t
    to int

    changeset: 87130:baab11a466ab
    user: Victor Stinner <victor.stinner@gmail.com>
    date: Fri Nov 15 23:26:25 2013 +0100
    files: Python/random.c
    description:
    Fix compiler warning in win32_urandom(): explicit cast to DWORD in
    CryptGenRandom()

    changeset: 87131:e086cb1c6e5a
    user: Victor Stinner <victor.stinner@gmail.com>
    date: Sat Nov 16 00:13:29 2013 +0100
    files: Python/marshal.c
    description:
    Fix compiler warning (on Windows 64-bit): explicit cast Py_ssize_t to unsigned
    char, n is in range [0; 255] (a tuple cannot have a negative length)

    changeset: 87132:cf399d13a707
    user: Victor Stinner <victor.stinner@gmail.com>
    date: Sat Nov 16 00:16:58 2013 +0100
    files: Include/asdl.h
    description:
    Fix compiler warning on Windows 64-bit: asdl_seq_SET() stores the index parameter
    into a Py_ssize_t, instead of an int

    changeset: 87133:309d855ebc3e
    user: Victor Stinner <victor.stinner@gmail.com>
    date: Sat Nov 16 00:17:22 2013 +0100
    files: Modules/_ctypes/_ctypes.c
    description:
    Fix compiler warning on Windows 64 bit: _init_pos_args() result type is
    Py_ssize_t, not int

    changeset: 87134:7cd4c3e9e310
    user: Victor Stinner <victor.stinner@gmail.com>
    date: Sat Nov 16 00:18:58 2013 +0100
    files: Modules/socketmodule.c
    description:
    Fix sock_recvfrom_guts(): recvfrom() size is limited to an int on Windows, not
    on other OSes!

    changeset: 87135:9e25367095c4
    user: Victor Stinner <victor.stinner@gmail.com>
    date: Sat Nov 16 00:27:16 2013 +0100
    files: Modules/_hashopenssl.c
    description:
    Fix compiler warnings on Windows 64 bit: add an explicit cast from Py_ssize_t
    to int, password.len was checked for being smaller than INT_MAX.

    changeset: 87229:ac4272df1af6
    user: Victor Stinner <victor.stinner@gmail.com>
    date: Mon Nov 18 01:07:38 2013 +0100
    files: Parser/grammar.c
    description:
    Fix compiler warnings on Windows 64-bit in grammar.c

    INT_MAX states and labels should be enough for everyone

    changeset: 87230:19e900e3033f
    user: Victor Stinner <victor.stinner@gmail.com>
    date: Mon Nov 18 01:09:51 2013 +0100
    files: Parser/parsetok.c
    description:
    Fix a compiler warning on Windows 64-bit in parsetok.c

    Python parser doesn't support lines longer than INT_MAX bytes yet

    changeset: 87231:103998db4407
    user: Victor Stinner <victor.stinner@gmail.com>
    date: Mon Nov 18 01:21:12 2013 +0100
    files: Python/getargs.c
    description:
    Use Py_ssize_t type for sizes in getargs.c

    Fix compiler warnings on Windows 64-bit

    changeset: 87232:0f7f1f2121a1
    user: Victor Stinner <victor.stinner@gmail.com>
    date: Mon Nov 18 01:24:31 2013 +0100
    files: Modules/_sqlite/connection.c
    description:
    sqlite: raise an OverflowError if the result is longer than INT_MAX bytes

    Fix a compiler warning on Windows 64-bit

    changeset: 87233:855e172bcac4
    user: Victor Stinner <victor.stinner@gmail.com>
    date: Mon Nov 18 01:27:30 2013 +0100
    files: Modules/_sqlite/row.c
    description:
    Fix a compiler warning on Windows 64-bit: _sqlite module

    changeset: 87234:40d25b2b93f0
    user: Victor Stinner <victor.stinner@gmail.com>
    date: Mon Nov 18 01:36:29 2013 +0100
    files: Modules/_sqlite/statement.c
    description:
    sqlite: raise an OverflowError if a string or a BLOB is longer than INT_MAX
    bytes

    Fix compiler warnings on Windows 64-bit

    changeset: 87235:d1dc7888656f
    user: Victor Stinner <victor.stinner@gmail.com>
    date: Mon Nov 18 02:05:31 2013 +0100
    files: Python/getargs.c
    description:
    PY_FORMAT_SIZE_T should not be used with PyErr_Format(), PyErr_Format("%zd") is
    portable

    changeset: 87236:2a01ca4b0edc
    user: Victor Stinner <victor.stinner@gmail.com>
    date: Mon Nov 18 02:07:29 2013 +0100
    files: Modules/_sqlite/statement.c
    description:
    sqlite: Use Py_ssize_t to store a size instead of an int

    Fix a compiler warning on Windows 64-bit

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 19, 2013

    New changeset 68fd86a83ece by Victor Stinner in branch 'default':
    Issue bpo-9566: compile.c uses Py_ssize_t instead of int to store sizes to fix
    http://hg.python.org/cpython/rev/68fd86a83ece

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 19, 2013

    New changeset 8d3e85dfa46f by Victor Stinner in branch 'default':
    Issue bpo-9566, bpo-19617: Fix compilation on Windows
    http://hg.python.org/cpython/rev/8d3e85dfa46f

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 19, 2013

    New changeset ee4da7291211 by Victor Stinner in branch 'default':
    Issue bpo-9566, bpo-19617: New try to fix compilation on Windows
    http://hg.python.org/cpython/rev/ee4da7291211

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 19, 2013

    New changeset 116bd550e309 by Victor Stinner in branch 'default':
    Issue bpo-9566, bpo-19617: Fix more compiler warnings in compile.c on Windows 64-bit
    http://hg.python.org/cpython/rev/116bd550e309

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jul 1, 2014

    Are there any more warnings that need silencing or can this be closed as fixed? How do I check for these warnings as I don't have a 64 bit machine?

    @vstinner
    Copy link
    Member

    vstinner commented Jul 1, 2014

    How do I check for these warnings as I don't have a 64 bit machine?

    Check buildbots. Example:
    http://buildbot.python.org/all/builders/AMD64%20Windows7%20SP1%203.x/builds/4744/steps/compile/logs/warnings%20%28108%29

    There are still open issues related to this one: bpo-18295 at least.

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Sep 24, 2015

    I've got the latest output with all of the warnings but I'm not sure where I should attach it as bpo-18295 and bpo-18407 also apply. There are also multiple deprecation warnings but I'm sure they've been discussed before. Can somebody please advise, thanks.

    @segevfiner
    Copy link
    Mannequin

    segevfiner mannequin commented Jun 29, 2017

    I submitted a PR which fixes some more warnings. The ones I haven't fixed are detailed in the PR description.

    @segevfiner segevfiner mannequin added the 3.7 (EOL) end of life label Jun 29, 2017
    @zooba
    Copy link
    Member

    zooba commented Jul 26, 2017

    New changeset e7bc7aa by Steve Dower (Segev Finer) in branch 'master':
    bpo-9566: Fix a warning in Python/getargs.c (bpo-2890)
    e7bc7aa

    @zooba
    Copy link
    Member

    zooba commented Jul 26, 2017

    New changeset 679b566 by Steve Dower (Segev Finer) in branch 'master':
    bpo-9566: Fix some Windows x64 compiler warnings (bpo-2492)
    679b566

    @zooba
    Copy link
    Member

    zooba commented Jul 26, 2017

    New changeset 5cff637 by Steve Dower (Segev Finer) in branch 'master':
    bpo-9566: Fixed _ssl module warnings (bpo-2495)
    5cff637

    @vstinner
    Copy link
    Member

    New changeset 679b566 by Steve Dower (Segev Finer) in branch 'master':
    bpo-9566: Fix some Windows x64 compiler warnings (bpo-2492)
    679b566

    This change broke AMD64 Windows7 SP1 3.x buildbot, see the logs for all errors:

    http://buildbot.python.org/all/builders/AMD64%20Windows7%20SP1%203.x/builds/796/steps/test/logs/stdio

    @segevfiner
    Copy link
    Mannequin

    segevfiner mannequin commented Jul 26, 2017

    @Haypo #2904

    @zooba
    Copy link
    Member

    zooba commented Jul 27, 2017

    New changeset a80e985 by Steve Dower (Segev Finer) in branch 'master':
    bpo-9566: Change HANDLE argument parsing to unsigned in msvcrtmodule.c (bpo-2904)
    a80e985

    @segevfiner
    Copy link
    Mannequin

    segevfiner mannequin commented Jul 27, 2017

    The only warnings that remain are:

    1. The one from gcmodule.c due to dtrace, which is handled in PR 2852.
    2. The peephole warnings which I'm not sure about. Are overflows possible there or not? That is, if there are already internal caps that prevent them. If they are possible, it might require a larger change to support EXTENDED_ARG in some places. i.e. can the consts table really grow larger than unsigned int or can a jump target be large enough to overflow?

    @pitrou
    Copy link
    Member Author

    pitrou commented Aug 20, 2017

    New changeset 0267128 by Antoine Pitrou (Segev Finer) in branch 'master':
    bpo-9566 & bpo-30747: Silence warnings from pyatomic.h macros (bpo-3140)
    0267128

    @vstinner
    Copy link
    Member

    New changeset 05d68a8 by Victor Stinner in branch 'master':
    bpo-9566: Fix size_t=>int downcast warnings (bpo-5230)
    05d68a8

    @vstinner
    Copy link
    Member

    New changeset 28f468c by Victor Stinner in branch 'master':
    bpo-9566: Fix compiler warnings in pyexpat.c (GH-10654)
    28f468c

    @vstinner
    Copy link
    Member

    There is also:

    commit cdbcb77
    Author: Victor Stinner <vstinner@redhat.com>
    Date: Thu Nov 22 10:25:46 2018 +0100

    cjkcodecs: Fix compiler warning (GH-10651)
    
    Fixed the following compiler warning in multibytecodec.c:
    
        warning C4244: '=': conversion from 'Py_ssize_t'
        to 'unsigned char', possible loss of data
    
    Cast Py_ssize_t to unsigned char: the maximum value is checked
    on the previous line.
    

    @jkloth
    Copy link
    Contributor

    jkloth commented Dec 7, 2018

    I've added two PRs (GH-11010 and python/issues-test-cpython#11011) along with bpo-35433 that should get 3.x warning free (finally!) on 64-bit Windows.

    @vstinner
    Copy link
    Member

    vstinner commented Dec 7, 2018

    New changeset 028f0ef by Victor Stinner in branch 'master':
    bpo-9566: Fix compiler warnings in peephole.c (GH-10652)
    028f0ef

    @vstinner
    Copy link
    Member

    vstinner commented Mar 6, 2019

    New changeset edad38e by Victor Stinner (Jeremy Kloth) in branch 'master':
    bpo-9566: Fix compiler warnings in gcmodule.c (GH-11010)
    edad38e

    @vstinner
    Copy link
    Member

    vstinner commented Mar 6, 2019

    New changeset edad38e by Victor Stinner (Jeremy Kloth) in branch 'master':
    bpo-9566: Fix compiler warnings in gcmodule.c (GH-11010)

    It fixed the last known warning. Thanks everyone who was involved in this funny ride. It's now time to close the issue!

    It just took 9 years to fix all compiler warnings on 64-bit Windows ;-)

    @vstinner vstinner closed this as completed Mar 6, 2019
    @vstinner
    Copy link
    Member

    New changeset 8a9a6b4 by Victor Stinner in branch '3.7':
    [3.7] bpo-9566: Fix compiler warnings on Windows (GH-12920)
    8a9a6b4

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life extension-modules C modules in the Modules dir interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    6 participants