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

RealPPPort.xs: "cast from pointer to integer of different size" using MinGW-w64 #20080

Closed
twata1 opened this issue Aug 11, 2022 · 14 comments
Closed
Labels
build-time-warnings Replaces [META] Build-time warnings RT #133556 distro-mswin32

Comments

@twata1
Copy link
Contributor

twata1 commented Aug 11, 2022

Description

I'am building Perl 5.37.2 on Windows 8.1 64 bit using MinGW-w64 (gcc (x86_64-posix-sjlj-rev0, Built by MinGW-W64 project) 8.1.0).

One of the build warnings is:

In file included from RealPPPort.xs:31:
RealPPPort.xs: In function 'XS_Devel__PPPort_ptrtests':
..\..\lib\CORE/perl.h:2481:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
 #  define INT2PTR(any,d) (any)(d)
                          ^
..\..\lib\CORE/perl.h:2494:21: note: in expansion of macro 'INT2PTR'
 #  define PTR2ul(p) INT2PTR(unsigned long,p)
                     ^~~~~~~
RealPPPort.xs:1831:27: note: in expansion of macro 'PTR2ul'
                 RETVAL += PTR2ul(p) != 0UL      ?  2 : 0;

Steps to Reproduce

Download perl-5.37.2.tar.gz from metacpan.
Extract from perl-5.37.2.tar.gz to C:\Perl64.

On command promput:

set PATH=C:\mingw64\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0
set CCHOME=C:\mingw64
cd C:\Perl64\perl-5.37.2\win32
gmake

Expected behavior

It is the suppression of warnings.

Perl configuration

C:\Perl64\perl-5.37.2\win32>C:\Perl64\perl-5.37.2\perl -V
Summary of my perl5 (revision 5 version 37 subversion 2) configuration:

  Platform:
    osname=MSWin32
    osvers=6.3.9600
    archname=MSWin32-x64-multi-thread
    uname=''
    config_args='undef'
    hint=recommended
    useposix=true
    d_sigaction=undef
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=undef
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='gcc'
    ccflags =' -DWIN32 -DWIN64  -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields'
    optimize='-O2'
    cppflags='-DWIN32'
    ccversion=''
    gccversion='8.1.0'
    gccosandvers=''
    intsize=4
    longsize=4
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='long long'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='g++'
    ldflags ='-s -L"c:\perl\lib\CORE" -L"C:\mingw64\lib" -L"C:\mingw64\x86_64-w64-mingw32\lib" -L"C:\mingw64\lib\gcc\x86_64-w64-mingw32\8.1.0"'
    libpth=C:\mingw64\lib C:\mingw64\x86_64-w64-mingw32\lib C:\mingw64\lib\gcc\x86_64-w64-mingw32\8.1.0
    libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversio
n -lodbc32 -lodbccp32 -lcomctl32
    perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    libc=
    so=dll
    useshrplib=true
    libperl=libperl537.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs
    dlext=dll
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags='-shared -s -L"c:\perl\lib\CORE" -L"C:\mingw64\lib" -L"C:\mingw64\x86_64-w64-mingw32\lib" -L"C:\mingw64\lib\gcc\x86_64-w64-mingw32\8.1.0"'


Characteristics of this binary (from libperl):
  Compile-time options:
    HAS_TIMES
    HAVE_INTERP_INTERN
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_IMPLICIT_SYS
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_SAFE_PUTENV
    USE_64_BIT_INT
    USE_ITHREADS
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
  Built under MSWin32
  Compiled at Aug 11 2022 14:30:37
  @INC:
    C:/Perl64/perl-5.37.2/lib

C:\Perl64\perl-5.37.2\win32>
@jkeenan jkeenan added distro-mswin32 build-time-warnings Replaces [META] Build-time warnings RT #133556 and removed Needs Triage labels Aug 11, 2022
@jkeenan
Copy link
Contributor

jkeenan commented Aug 11, 2022

(Note: I don't have Windows, so my own ability to diagnose this problem is limited.)

Can you provide a bit more context for the build-time warning you posted above? For instance, can you post some of the commands which make executes immediately before the warning is generated?

For example, when on FreeBSD I search for RealPPPort in the output of make, I get an area like this:

"../../miniperl" "-I../../lib" "-I../../lib" RealPPPort_xs.PL RealPPPort.xs
adding XS code from parts/inc/HvNAME
adding XS code from parts/inc/MY_CXT
adding XS code from parts/inc/SvPV
adding XS code from parts/inc/SvREFCNT
adding XS code from parts/inc/Sv_set
adding XS code from parts/inc/call
adding XS code from parts/inc/cop
adding XS code from parts/inc/exception
adding XS code from parts/inc/format
adding XS code from parts/inc/grok
adding XS code from parts/inc/gv
adding XS code from parts/inc/limits
/RealPPPort 
adding XS code from parts/inc/snprintf
adding XS code from parts/inc/sprintf
adding XS code from parts/inc/strlfuncs
adding XS code from parts/inc/sv_xpvf
adding XS code from parts/inc/threads
adding XS code from parts/inc/utf8
adding XS code from parts/inc/uv
adding XS code from parts/inc/variables
adding XS code from parts/inc/warn
"../../miniperl" "-I../../lib" "../../lib/ExtUtils/xsubpp" -noprototypes -typemap '/usr/home/jkeenan/gitwork/perl/dist/Devel-PPPort/../../lib/ExtUtils/typemap' -typemap '/usr/home/jkeenan/gitwork/perl/dist/Devel-PPPort/typemap'  RealPPPort.xs > RealPPPort.xsc
mv RealPPPort.xsc RealPPPort.c
gcc10 -c    -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_FORTIFY_SOURCE=2 -Wall -Werror=pointer-arith -Werror=vla -Wextra -Wno-long-long -Wno-declaration-after-statement -Wc++-compat -Wwrite-strings -O2 -g    -DVERSION=\"3.68\"  -DXS_VERSION=\"3.68\" -DPIC -fPIC "-I../.."  -W -Wall RealPPPort.c
gcc10 -c    -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_FORTIFY_SOURCE=2 -Wall -Werror=pointer-arith -Werror=vla -Wextra -Wno-long-long -Wno-declaration-after-statement -Wc++-compat -Wwrite-strings -O2 -g    -DVERSION=\"3.68\"  -DXS_VERSION=\"3.68\" -DPIC -fPIC "-I../.."  -W -Wall module2.c

Is your area similar to that one?

@jkeenan
Copy link
Contributor

jkeenan commented Aug 11, 2022

I'am building Perl 5.37.2 on Windows 8.1 64 bit using MinGW-w64 (gcc (x86_64-posix-sjlj-rev0, Built by MinGW-W64 project) 8.1.0).

Do you have the capability of trying any later version of gcc here?

I ask because it's my impression that certain build-time warnings I got with older versions of gcc simply went away once I was able to compile with, say, gcc-9, gcc-10 or later (although those later versions did introduce new build-time warnings).

@twata1
Copy link
Contributor Author

twata1 commented Aug 11, 2022

Thanks for the reply. Just where I can cope with quick.

| Do you have the capability of trying any later version of gcc here?

No. The gcc binaries I was able to find were up to 8.3.

@Leont
Copy link
Contributor

Leont commented Aug 11, 2022

The warning isn't wrong (unsigned long on Windows would be 32 bits, and the pointer 64 bits), just rather useless.

@sisyphus
Copy link
Contributor

sisyphus commented Aug 12, 2022

The gcc binaries I was able to find were up to 8.3.

For more recent versions (of both gcc and mingw runtime) see https://winlibs.com/ .
For perl, you'll want one of the "MSVCRT releases". (AFAIK the "UCRT releases" won't build perl.)
I have been using compilers from there for the last couple of years.

If you use gcc-12.1.0, the 64-bit version won't build perl-5.36.0 or earlier unless you patch the source (see #19824).
There's also another issue with some perl configurations using that x64 compiler - see #20024

Update: However, it builds current blead .

AFAIK, their earlier versions of gcc avoid all of those issues.

Cheers,
Rob

@sisyphus
Copy link
Contributor

The warning isn't wrong (unsigned long on Windows would be 32 bits, and the pointer 64 bits), just rather useless.

It's not apparent to me why warning about casting a pointer to an unsigned long is useless.

Cheers,
Rob

@twata1
Copy link
Contributor Author

twata1 commented Aug 12, 2022

Thank you all for your replies.

@jkeenan

Can you provide a bit more context for the build-time warning you posted above?

Yes. It was as follows.

"C:\Perl64\perl-5.37.2\miniperl.exe" "-I..\..\lib" "-I..\..\lib" RealPPPort_xs.PL RealPPPort.xs 
adding XS code from parts\inc\HvNAME
adding XS code from parts\inc\MY_CXT
adding XS code from parts\inc\SvPV
adding XS code from parts\inc\SvREFCNT
adding XS code from parts\inc\Sv_set
adding XS code from parts\inc\call
adding XS code from parts\inc\cop
adding XS code from parts\inc\exception
adding XS code from parts\inc\format
adding XS code from parts\inc\grok
adding XS code from parts\inc\gv
adding XS code from parts\inc\limits
adding XS code from parts\inc\locale
adding XS code from parts\inc\mPUSH
adding XS code from parts\inc\magic
adding XS code from parts\inc\memory
adding XS code from parts\inc\mess
adding XS code from parts\inc\misc
adding XS code from parts\inc\newCONSTSUB
adding XS code from parts\inc\newRV
adding XS code from parts\inc\newSV_type
adding XS code from parts\inc\newSVpv
adding XS code from parts\inc\pv_tools
adding XS code from parts\inc\pvs
adding XS code from parts\inc\shared_pv
adding XS code from parts\inc\snprintf
adding XS code from parts\inc\sprintf
adding XS code from parts\inc\strlfuncs
adding XS code from parts\inc\sv_xpvf
adding XS code from parts\inc\threads
adding XS code from parts\inc\utf8
adding XS code from parts\inc\uv
adding XS code from parts\inc\variables
adding XS code from parts\inc\warn
"C:\Perl64\perl-5.37.2\miniperl.exe" "-I..\..\lib" "C:\Perl64\perl-5.37.2\dist\ExtUtils-ParseXS\lib\ExtUtils/xsubpp" -noprototypes -typemap C:\Perl64\perl-5.37.2\lib\ExtUtils\typemap -typemap C:\Perl64\perl-5.37.2\dist\Devel-PPPort\typemap  RealPPPort.xs > RealPPPort.xsc
"C:\Perl64\perl-5.37.2\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e mv -- RealPPPort.xsc RealPPPort.c
gcc -c   -DWIN32 -DWIN64 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -O2   -DVERSION=\"3.68\" -DXS_VERSION=\"3.68\"  "-I..\..\lib\CORE"  -W -Wall RealPPPort.c
In file included from RealPPPort.xs:31:
RealPPPort.xs: In function 'XS_Devel__PPPort_ptrtests':
..\..\lib\CORE/perl.h:2481:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
 #  define INT2PTR(any,d) (any)(d)
                          ^
..\..\lib\CORE/perl.h:2494:21: note: in expansion of macro 'INT2PTR'
 #  define PTR2ul(p) INT2PTR(unsigned long,p)
                     ^~~~~~~
RealPPPort.xs:1831:27: note: in expansion of macro 'PTR2ul'
                 RETVAL += PTR2ul(p) != 0UL      ?  2 : 0;
                           ^~~~~~
gcc -c   -DWIN32 -DWIN64 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -O2   -DVERSION=\"3.68\" -DXS_VERSION=\"3.68\"  "-I..\..\lib\CORE"  -W -Wall module2.c
gcc -c   -DWIN32 -DWIN64 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -O2   -DVERSION=\"3.68\" -DXS_VERSION=\"3.68\"  "-I..\..\lib\CORE"  -W -Wall module3.c

For instance, can you post some of the commands which make executes immediately before the warning is generated?

I also attached build.log. (The log file is converted to utf8 because a few Japanese sentences are mixed in places. Several other warning messages are also output.)
gmake-2022-08-12.log

Is your area similar to that one?

I think I have a warning message output but it is roughly similar.

I will try gcc-10 tomorrow or the next day or two.

@Leont
Thank you for your comment.
I will ignore it if the warning isn't wrong.
In fact, there are other warnings outputted, and I would like to confirm whether or not I can ignore them one by one, but I hope they will disappear by using gcc-10.

@sisyphus
Thank you for telling me where to find more recent versions (of both gcc and mingw runtime) and the helpful information on the build. In the meantime, I will try gcc-10 tomorrow or the next day or two.

@twata1
Copy link
Contributor Author

twata1 commented Aug 14, 2022

Hello everyone.

I have been able to confirm that both gcc-10 and gcc-11 produce the same warning as gcc-8.1.
But I will ignore it if the warning isn't wrong.
(Other warnings are output, but I won't mention them here because they are far from the content of this title.)

Overview of Execution Commands for gcc-10:

set PATH=C:\winlibs-x86_64-posix-seh-gcc-10.3.0-llvm-12.0.0-mingw-w64-9.0.0-r2\mingw64\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0
set CCHOME=C:\winlibs-x86_64-posix-seh-gcc-10.3.0-llvm-12.0.0-mingw-w64-9.0.0-r2\mingw64
cd C:\Perl64-gcc10\perl-5.37.2\win32
gmake > gmake-2022-08-14-gcc-10.log 2>&1

Relevant part of the log:

"C:\Perl64-gcc10\perl-5.37.2\miniperl.exe" "-I..\..\lib" "-I..\..\lib" RealPPPort_xs.PL RealPPPort.xs 
adding XS code from parts\inc\HvNAME
adding XS code from parts\inc\MY_CXT
adding XS code from parts\inc\SvPV
adding XS code from parts\inc\SvREFCNT
adding XS code from parts\inc\Sv_set
adding XS code from parts\inc\call
adding XS code from parts\inc\cop
adding XS code from parts\inc\exception
adding XS code from parts\inc\format
adding XS code from parts\inc\grok
adding XS code from parts\inc\gv
adding XS code from parts\inc\limits
adding XS code from parts\inc\locale
adding XS code from parts\inc\mPUSH
adding XS code from parts\inc\magic
adding XS code from parts\inc\memory
adding XS code from parts\inc\mess
adding XS code from parts\inc\misc
adding XS code from parts\inc\newCONSTSUB
adding XS code from parts\inc\newRV
adding XS code from parts\inc\newSV_type
adding XS code from parts\inc\newSVpv
adding XS code from parts\inc\pv_tools
adding XS code from parts\inc\pvs
adding XS code from parts\inc\shared_pv
adding XS code from parts\inc\snprintf
adding XS code from parts\inc\sprintf
adding XS code from parts\inc\strlfuncs
adding XS code from parts\inc\sv_xpvf
adding XS code from parts\inc\threads
adding XS code from parts\inc\utf8
adding XS code from parts\inc\uv
adding XS code from parts\inc\variables
adding XS code from parts\inc\warn
"C:\Perl64-gcc10\perl-5.37.2\miniperl.exe" "-I..\..\lib" "C:\Perl64-gcc10\perl-5.37.2\dist\ExtUtils-ParseXS\lib\ExtUtils/xsubpp" -noprototypes -typemap C:\Perl64-gcc10\perl-5.37.2\lib\ExtUtils\typemap -typemap C:\Perl64-gcc10\perl-5.37.2\dist\Devel-PPPort\typemap  RealPPPort.xs > RealPPPort.xsc
"C:\Perl64-gcc10\perl-5.37.2\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e mv -- RealPPPort.xsc RealPPPort.c
gcc -c   -DWIN32 -DWIN64 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -O2   -DVERSION=\"3.68\" -DXS_VERSION=\"3.68\"  "-I..\..\lib\CORE"  -W -Wall RealPPPort.c
In file included from RealPPPort.xs:31:
RealPPPort.xs: In function 'XS_Devel__PPPort_ptrtests':
..\..\lib\CORE/perl.h:2481:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
 2481 | #  define INT2PTR(any,d) (any)(d)
      |                          ^
..\..\lib\CORE/perl.h:2494:21: note: in expansion of macro 'INT2PTR'
 2494 | #  define PTR2ul(p) INT2PTR(unsigned long,p)
      |                     ^~~~~~~
RealPPPort.xs:1831:27: note: in expansion of macro 'PTR2ul'
 1831 |                 RETVAL += PTR2ul(p) != 0UL      ?  2 : 0;
      |                           ^~~~~~
gcc -c   -DWIN32 -DWIN64 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -O2   -DVERSION=\"3.68\" -DXS_VERSION=\"3.68\"  "-I..\..\lib\CORE"  -W -Wall module2.c
gcc -c   -DWIN32 -DWIN64 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -O2   -DVERSION=\"3.68\" -DXS_VERSION=\"3.68\"  "-I..\..\lib\CORE"  -W -Wall module3.c

Full log (copy command results translated into English):
gmake-2022-08-14-with-gcc-10.log

I incidentally also tried it with gcc-11.

Overview of Execution Commands for gcc-11:

set PATH=C:\winlibs-x86_64-posix-seh-gcc-11.3.0-llvm-14.0.3-mingw-w64msvcrt-10.0.0-r3\mingw64\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0
set CCHOME=C:\winlibs-x86_64-posix-seh-gcc-11.3.0-llvm-14.0.3-mingw-w64msvcrt-10.0.0-r3\mingw64
cd C:\Perl64-gcc11\perl-5.37.2\win32
gmake > gmake-2022-08-14-gcc11.log 2>&1

Relevant part of the log:

"C:\Perl64-gcc11\perl-5.37.2\miniperl.exe" "-I..\..\lib" "-I..\..\lib" RealPPPort_xs.PL RealPPPort.xs 
adding XS code from parts\inc\HvNAME
adding XS code from parts\inc\MY_CXT
adding XS code from parts\inc\SvPV
adding XS code from parts\inc\SvREFCNT
adding XS code from parts\inc\Sv_set
adding XS code from parts\inc\call
adding XS code from parts\inc\cop
adding XS code from parts\inc\exception
adding XS code from parts\inc\format
adding XS code from parts\inc\grok
adding XS code from parts\inc\gv
adding XS code from parts\inc\limits
adding XS code from parts\inc\locale
adding XS code from parts\inc\mPUSH
adding XS code from parts\inc\magic
adding XS code from parts\inc\memory
adding XS code from parts\inc\mess
adding XS code from parts\inc\misc
adding XS code from parts\inc\newCONSTSUB
adding XS code from parts\inc\newRV
adding XS code from parts\inc\newSV_type
adding XS code from parts\inc\newSVpv
adding XS code from parts\inc\pv_tools
adding XS code from parts\inc\pvs
adding XS code from parts\inc\shared_pv
adding XS code from parts\inc\snprintf
adding XS code from parts\inc\sprintf
adding XS code from parts\inc\strlfuncs
adding XS code from parts\inc\sv_xpvf
adding XS code from parts\inc\threads
adding XS code from parts\inc\utf8
adding XS code from parts\inc\uv
adding XS code from parts\inc\variables
adding XS code from parts\inc\warn
"C:\Perl64-gcc11\perl-5.37.2\miniperl.exe" "-I..\..\lib" "C:\Perl64-gcc11\perl-5.37.2\dist\ExtUtils-ParseXS\lib\ExtUtils/xsubpp" -noprototypes -typemap C:\Perl64-gcc11\perl-5.37.2\lib\ExtUtils\typemap -typemap C:\Perl64-gcc11\perl-5.37.2\dist\Devel-PPPort\typemap  RealPPPort.xs > RealPPPort.xsc
"C:\Perl64-gcc11\perl-5.37.2\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e mv -- RealPPPort.xsc RealPPPort.c
gcc -c   -DWIN32 -DWIN64 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -O2   -DVERSION=\"3.68\" -DXS_VERSION=\"3.68\"  "-I..\..\lib\CORE"  -W -Wall RealPPPort.c
In file included from RealPPPort.xs:31:
RealPPPort.xs: In function 'XS_Devel__PPPort_ptrtests':
..\..\lib\CORE/perl.h:2481:33: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
 2481 | #  define INT2PTR(any,d)        (any)(d)
      |                                 ^
..\..\lib\CORE/perl.h:2494:25: note: in expansion of macro 'INT2PTR'
 2494 | #  define PTR2ul(p)     INT2PTR(unsigned long,p)
      |                         ^~~~~~~
RealPPPort.xs:1831:27: note: in expansion of macro 'PTR2ul'
 1831 |                 RETVAL += PTR2ul(p) != 0UL      ?  2 : 0;
      |                           ^~~~~~
gcc -c   -DWIN32 -DWIN64 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -O2   -DVERSION=\"3.68\" -DXS_VERSION=\"3.68\"  "-I..\..\lib\CORE"  -W -Wall module2.c
gcc -c   -DWIN32 -DWIN64 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -O2   -DVERSION=\"3.68\" -DXS_VERSION=\"3.68\"  "-I..\..\lib\CORE"  -W -Wall module3.c

Full log (copy command results translated into English):
gmake-2022-08-14-with-gcc11.log

Thank you,

@sisyphus
Copy link
Contributor

sisyphus commented Aug 14, 2022

But I will ignore it if the warning isn't wrong

The thing is that, on 64-bit Windows, the condition (PTR2ul(p) != 0UL) will never be falsely TRUE.
That is, if it returns TRUE, then we can be certain that the pointer was not null && that PTR2ul functioned correctly..

And it could only return FALSE when it should have returned TRUE if the value held by the pointer overflows 32-bits && the low 32 bits are all zero - which is a scenario that seems most unlikely.
It may even be impossible (?) - some testing I did found that the pointer was always less than 0x500000, and there's certainly no problem associated with casting those values to an unsigned long on Windows.
(But I've no idea what the rules are regarding the system's assigning of address locations.)

So, @twata1, I think it's pretty safe to ignore them.
But there's a little voice telling me that it would be better to pre-process PTR2ul out of the way on perls where ptrsize is greater than longsize .... free us from the noise, and just rely on PTR2UV (which is already being tested, and makes better sense.)

Cheers,
Rob

@Leont
Copy link
Contributor

Leont commented Aug 14, 2022

But there's a little voice telling me that it would be better to pre-process PTR2ul out of the way on perls where ptrsize is greater than longsize .... free us from the noise, and just rely on PTR2UV (which is already being tested, and makes better sense.)

Agreed

@twata1
Copy link
Contributor Author

twata1 commented Aug 14, 2022

So, @twata1, I think it's pretty safe to ignore them.

Ok. I ignore the warning ( and if I ever have the opportunity to cast longsize, I will rely on PTR2UV. )
Thank you. I appreciate it!

@sisyphus
Copy link
Contributor

Turns out that this is a duplicate of Dual-Life/Devel-PPPort#107 .
I think that's the more appropriate forum for discussion of the problem, and I suggest that this "Issue" be closed and further discussion should take place at Dual-Life/Devel-PPPort#107 where I've submitted the following patch for review:

--- misc_orig   2022-08-16 15:14:57.318512000 +1000
+++ misc_mod    2022-08-16 14:45:11.000000000 +1000
@@ -1129,6 +1129,13 @@

 =xsmisc

+/* Avoid PTR2ul calls in the code if PTRSIZE > LONGSIZE */
+#if PTRSIZE > LONGSIZE
+#  define PTR2U(p) PTR2UV(p)
+#else
+#  define PTR2U(p) PTR2ul(p)
+#endif
+
 typedef XSPROTO(XSPROTO_test_t);
 typedef XSPROTO_test_t *XSPROTO_test_t_ptr;

@@ -1267,7 +1274,12 @@
         CODE:
                 RETVAL = 0;
                 RETVAL += PTR2nat(p) != 0       ?  1 : 0;
-                RETVAL += PTR2ul(p) != 0UL      ?  2 : 0;
+
+                /* If PTRSIZE > LONGSIZE PTR2U(p) is defined
+                 * as PTR2UV(p) as PTR2ul(p) is inappropriate.
+                 * Else PTR2U(p) is defined as PTR2ul(p) */
+                RETVAL += PTR2U(p)  != 0UL      ?  2 : 0;
+
                 RETVAL += PTR2UV(p) != (UV) 0   ?  4 : 0;
                 RETVAL += PTR2IV(p) != (IV) 0   ?  8 : 0;
                 RETVAL += PTR2NV(p) != (NV) 0   ? 16 : 0;

Cheers,
Rob

@sisyphus
Copy link
Contributor

I think that's the more appropriate forum for discussion of the problem, and I suggest that this "Issue" be closed ....

Actually, that might be incorrect. Right here is the more appropriate forum if I understand https://perldoc.perl.org/perlsource correctly.

Cheers,
Rob

@twata1
Copy link
Contributor Author

twata1 commented Aug 17, 2022

@sisyphus

Turns out that this is a duplicate of Dual-Life/Devel-PPPort#107 .

Thank you for your suggestion.

I did not know Dual-Life module GitHub repository existed.
I too think it would be better to discuss this at Dual-Life/Devel-PPPort#107 .

I will close this ticket.

@twata1 twata1 closed this as completed Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build-time-warnings Replaces [META] Build-time warnings RT #133556 distro-mswin32
Projects
None yet
Development

No branches or pull requests

4 participants