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

runtime/cgo: cannot build with -Wsign-conversion or -Wshorten-64-to-32 #48122

Closed
elagergren-spideroak opened this issue Sep 1, 2021 · 2 comments

Comments

@elagergren-spideroak
Copy link

Same environment and test program as #48121, but with -Wsign-conversion and -Wshorten-64-to-32:

gcc_sigaction.c:55:33: error: implicit conversion changes signedness: 'int' to 'unsigned long' [-Werror,-Wsign-conversion]
gcc_sigaction.c:77:28: error: implicit conversion changes signedness: 'int' to 'uint64_t' (aka 'unsigned long') [-Werror,-Wsign-conversion]
gcc_sigaction.c:52:30: error: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Werror,-Wshorten-64-to-32]
gcc_sigaction.c:55:31: error: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Werror,-Wshorten-64-to-32]
gcc_sigaction.c:58:18: error: implicit conversion loses integer precision: 'intptr_t' (aka 'long') to 'int' [-Werror,-Wshorten-64-to-32]
gcc_sigaction.c:73:38: error: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Werror,-Wshorten-64-to-32]
@elagergren-spideroak elagergren-spideroak changed the title runtime/cgo: cannot build with -Wsign-conversion or -Wshorten-64-to-32 runtime/cgo: cannot build with -Wsign-conversion Sep 1, 2021
@elagergren-spideroak elagergren-spideroak changed the title runtime/cgo: cannot build with -Wsign-conversion runtime/cgo: cannot build with -Wsign-conversion or -Wshorten-64-to-32 Sep 1, 2021
@elagergren-spideroak
Copy link
Author

elagergren-spideroak commented Sep 1, 2021

Some GCC output directly from CI (code is different from the minimal repro in #48121):

GCC 8 and 9:

cgo-gcc-prolog:6:74: error: unsigned conversion from ?int? to ?long unsigned int? changes value from ?-2? to ?18446744073709551614? [-Werror=sign-conversion]
cgo-gcc-prolog:9:33: note: in expansion of macro ?__cgo_compile_assert_eq?
cgo-gcc-prolog:11:1: note: in expansion of macro ?__cgo_size_assert?
gcc_sigaction.c: In function 'x_cgo_sigaction':
gcc_sigaction.c:52:30: error: conversion from 'size_t' {aka 'long unsigned int'} to 'int' may change value [-Werror=conversion]
     sigaddset(&act.sa_mask, i+1);
                             ~^~
gcc_sigaction.c:55:18: error: conversion from 'long unsigned int' to 'int' may change value [-Werror=conversion]
   act.sa_flags = goact->flags & ~SA_RESTORER;
                  ^~~~~
gcc_sigaction.c:58:18: error: conversion from 'intptr_t' {aka 'long int'} to 'int' may change value [-Werror=conversion]
  ret = sigaction(signum, goact ? &act : NULL, oldgoact ? &oldact : NULL);
                  ^~~~~~
gcc_sigaction.c:73:38: error: conversion from 'size_t' {aka 'long unsigned int'} to 'int' may change value [-Werror=conversion]
    if (sigismember(&oldact.sa_mask, i+1) == 1) {

@cherrymui
Copy link
Member

cherrymui commented Sep 1, 2021

This and #48121 are similar enough. I think we can combine them and continue there. Thanks.

@golang golang locked and limited conversation to collaborators Sep 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants