-
Notifications
You must be signed in to change notification settings - Fork 602
Description
Description
t\porting\cpphdrcheck.t added in #22232 won't pass with mingw64 gcc 8.3.0, syntax error b/c of missing c++ header files (my guess) in the sample .cpp files it uses
STDOUT stream of t\porting\cpphdrcheck.t
# test run for g++
# probe g++ for standard C++11 with -std=c++11
# found 11 with -std=c++11
# probe g++ for standard C++14 with -std=c++14
# found 14 with -std=c++14
# probe g++ for standard C++17 with -std=c++17
# found 17 with -std=c++17
# probe g++ for standard C++20 with -std=c++20
# didn't find 20 with -std=c++20
# build: g++ -oa.out.exe -DWIN32 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -std=c++20 source.cpp 2>&1
#
# build output: g++: error: unrecognized command line option '-std=c++20'; did you mean '-std=c++2a'?
#
# build exit: 256
# probe g++ for standard C++23 with -std=c++23
# didn't find 23 with -std=c++23
# build: g++ -oa.out.exe -DWIN32 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -std=c++23 source.cpp 2>&1
#
# build output: g++: error: unrecognized command line option '-std=c++23'; did you mean '-std=c++03'?
#
# build exit: 256
ok 1 - test std base
# cmd: g++ -c -DWIN32 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -IC:\sources\perl5 -IC:\sources\perl5\lib\CORE source.cpp 2>&1
# out:
not ok 2 - test std 11
not ok 3 - test std 14
not ok 4 - test std 17
1..4
trimmed piece of g++ --help=c++ from the binary
-iwithprefixbefore <dir> Add <dir> to the end of the main include path.
-nostdinc Do not search standard system include directories
(those specified with -isystem will still be
used).
-nostdinc++ Do not search standard system include directories
for C++.
-o <file> Place output into <file>.
-pedantic Same as -Wpedantic. Use the latter option
instead.
-remap Remap file names when including files.
-std=c++03 Conform to the ISO 1998 C++ standard revised by
the 2003 technical corrigendum. Same as
-std=c++98.
-std=c++0x Deprecated in favor of -std=c++11. Same as
-std=c++11.
-std=c++11 Conform to the ISO 2011 C++ standard.
-std=c++14 Conform to the ISO 2014 C++ standard.
-std=c++17 Conform to the ISO 2017 C++ standard.
-std=c++1y Deprecated in favor of -std=c++14. Same as
-std=c++14.
-std=c++1z Deprecated in favor of -std=c++17. Same as
-std=c++17.
-std=c++2a Conform to the ISO 2020(?) C++ draft standard
(experimental and incomplete support).
-std=c++98 Conform to the ISO 1998 C++ standard revised by
the 2003 technical corrigendum.
-std=gnu++03 Conform to the ISO 1998 C++ standard revised by
the 2003 technical corrigendum with GNU
extensions. Same as -std=gnu++98.
-std=gnu++0x Deprecated in favor of -std=gnu++11. Same as
-std=gnu++11.
-std=gnu++11 Conform to the ISO 2011 C++ standard with GNU
extensions.
-std=gnu++14 Conform to the ISO 2014 C++ standard with GNU
extensions.
-std=gnu++17 Conform to the ISO 2017 C++ standard with GNU
extensions.
-std=gnu++1y Deprecated in favor of -std=gnu++14. Same as
-std=gnu++14.
-std=gnu++1z Deprecated in favor of -std=gnu++17. Same as
-std=gnu++17.
-std=gnu++2a Conform to the ISO 2020(?) C++ draft standard
with GNU extensions (experimental and incomplete
support).
-std=gnu++98 Conform to the ISO 1998 C++ standard revised by
the 2003 technical corrigendum with GNU
extensions.
-traditional-cpp Enable traditional preprocessing.
-trigraphs Support ISO C trigraphs.
-undef Do not predefine system-specific and GCC-specific
macros.
-v Enable verbose output.
-w Suppress warnings.
C:\sources\perl5\win32>where g++
C:\Strawberry\c\bin\g++.exe
C:\sources\perl5\win32>g++ -dumpmachine
i686-w64-mingw32
C:\sources\perl5\win32>g++ -dumpversion
8.3.0
C:\sources\perl5\win32>g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=C:/Strawberry/c/bin/../libexec/gcc/i686-w64-mingw32/8.3.0/lt
o-wrapper.exe
Target: i686-w64-mingw32
Configured with: ../../../src/gcc-8.3.0/configure --host=i686-w64-mingw32 --buil
d=i686-w64-mingw32 --target=i686-w64-mingw32 --prefix=/mingw32 --enable-shared -
-enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-
libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --
enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-st
ring --enable-version-specific-runtime-libs --enable-libstdcxx-filesystem-ts=yes
--disable-sjlj-exceptions --with-dwarf2 --disable-libstdcxx-pch --disable-libst
dcxx-debug --disable-bootstrap --disable-rpath --disable-win32-registry --disabl
e-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch
=i686 --with-tune=generic --with-libiconv --with-system-zlib --with-gmp=/opt/bui
ld/prerequisites/i686-w64-mingw32-static --with-mpfr=/opt/build/prerequisites/i6
86-w64-mingw32-static --with-mpc=/opt/build/prerequisites/i686-w64-mingw32-stati
c --with-isl=/opt/build/prerequisites/i686-w64-mingw32-static --with-pkgversion=
'i686-posix-dwarf, Built by strawberryperl.com project' --with-bugurl=https://so
urceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/opt/build/i686-
830-posix-dwarf-rt_v6/mingw32/opt/include -I/opt/build/prerequisites/i686-zlib-s
tatic/include -I/opt/build/prerequisites/i686-w64-mingw32-static/include' CXXFLA
GS='-O2 -pipe -fno-ident -I/opt/build/i686-830-posix-dwarf-rt_v6/mingw32/opt/inc
lude -I/opt/build/prerequisites/i686-zlib-static/include -I/opt/build/prerequisi
tes/i686-w64-mingw32-static/include' CPPFLAGS=' -I/opt/build/i686-830-posix-dwar
f-rt_v6/mingw32/opt/include -I/opt/build/prerequisites/i686-zlib-static/include
-I/opt/build/prerequisites/i686-w64-mingw32-static/include' LDFLAGS='-pipe -fno-
ident -L/opt/build/i686-830-posix-dwarf-rt_v6/mingw32/opt/lib -L/opt/build/prere
quisites/i686-zlib-static/lib -L/opt/build/prerequisites/i686-w64-mingw32-static
/lib -Wl,--large-address-aware' LD_FOR_TARGET=/opt/build/i686-830-posix-dwarf-rt
_v6/mingw32/bin/ld.exe
Thread model: posix
gcc version 8.3.0 (i686-posix-dwarf, Built by strawberryperl.com project)
C:\sources\perl5\win32>
The GCC 8.3.0 binary+SDK being used isthe one bundled with Strawberry 5.32.1. Below is the -V of the bundled perl it came with, but this
C:\sources\perl5\win32>perl -V
Summary of my perl5 (revision 5 version 32 subversion 1) configuration:
Platform:
osname=MSWin32
osvers=10.0.19042.746
archname=MSWin32-x86-multi-thread-64int
uname='Win32 strawberry-perl 5.32.1.1 #1 Sun Jan 24 12:17:47 2021 i386'
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
bincompat5005=undef
Compiler:
cc='gcc'
ccflags =' -DWIN32 -D__USE_MINGW_ANSI_STDIO -DPERL_TEXTMODE_SCRIPTS -DPERL_I
MPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -fwrapv -fno-strict-aliasing -m
ms-bitfields'
optimize='-s -O2'
cppflags='-DWIN32'
ccversion=''
gccversion='8.3.0'
gccosandvers=''
intsize=4
longsize=4
ptrsize=4
doublesize=8
byteorder=12345678
doublekind=3
d_longlong=define
longlongsize=8
d_longdbl=define
longdblsize=12
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:\STRAWB~1\perl\lib\CORE" -L"C:\STRAWB~1\c\lib"'
libpth=C:\STRAWB~1\c\lib C:\STRAWB~1\c\i686-w64-mingw32\lib C:\STRAWB~1\c\li
b\gcc\i686-w64-mingw32\8.3.0
libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi3
2 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversio
n -lodbc32 -lodbccp32 -lcomctl32
perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladv
api32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lve
rsion -lodbc32 -lodbccp32 -lcomctl32
libc=
so=dll
useshrplib=true
libperl=libperl532.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_win32.xs
dlext=xs.dll
d_dlsymun=undef
ccdlflags=' '
cccdlflags=' '
lddlflags='-mdll -s -L"C:\STRAWB~1\perl\lib\CORE" -L"C:\STRAWB~1\c\lib"'
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_CONTEXT
PERL_IMPLICIT_SYS
PERL_MALLOC_WRAP
PERL_OP_PARENT
PERL_PRESERVE_IVUV
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 Jan 24 2021 12:22:49
%ENV:
PERL_JSON_BACKEND="Cpanel::JSON::XS"
PERL_YAML_BACKEND="YAML::XS"
@INC:
C:/Strawberry/perl/site/lib
C:/Strawberry/perl/vendor/lib
C:/Strawberry/perl/lib
C:\sources\perl5\win32>
Steps to Reproduce
This probably isn't 100% identical to what is in cpphdrcheck.t but shows it has nothing to do perl API in C++ code but something in the non-perl C API related cmd line args cpphdrcheck.t given to g++ or missing #defines, or broken CC detection logic in cpphdrcheck.t.
This file fails
#include <new> // line not inside `cpphdrcheck.t` I added it but still failed same errors
#include <iostream>
#include <memory>
//#include "EXTERN.h" // disabled to reduce things going wrong
//#include "perl.h"
//#include "XSUB.h"
struct A {
virtual const char *ok() { return "NOT OK\n"; };
// = default C++11
virtual ~A() = default;
};
struct B : A {
// override C++11
const char *ok() override { return "OK\n"; };
};
// unique ptr is C++11
std::unique_ptr<A> f() {
return std::unique_ptr<A>{new B};
}
int main() {
// auto as a placeholder type is C++11
auto p = f();
std::cout << p->ok();
return 0;
}
when compiled by hand with
g++ -c -DWIN32 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -IC:\sources\perl5 -IC:\sources\perl5\lib\CORE -std=c++17 source2.cpp
console log of failed .cpp sample
In file included from C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++
/memory:66,
from source2.cpp:3:
C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++/bits/stl_tempbuf.h: I
n function 'std::pair<_Tp*, int> std::get_temporary_buffer(std::ptrdiff_t)':
C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++/bits/stl_tempbuf.h:95
:13: error: 'nothrow' is not a member of 'std'
std::nothrow));
^~~~~~~
C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++/bits/stl_tempbuf.h: I
n function 'void std::return_temporary_buffer(_Tp*)':
C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++/bits/stl_tempbuf.h:11
3:35: error: 'nothrow' is not a member of 'std'
{ ::operator delete(__p, std::nothrow); }
^~~~~~~
In file included from C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++
/bits/shared_ptr.h:52,
from C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++
/memory:81,
from source2.cpp:3:
C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++/bits/shared_ptr_base.
h: At global scope:
C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++/bits/shared_ptr_base.
h:723:61: error: 'std::nothrow_t' has not been declared
explicit __shared_count(const __weak_count<_Lp>& __r, std::nothrow_t);
^~~
C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++/bits/shared_ptr_base.
h:905:50: error: 'std::nothrow_t' has not been declared
__shared_count(const __weak_count<_Lp>& __r, std::nothrow_t)
^~~
C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++/bits/shared_ptr_base.
h:1352:53: error: 'std::nothrow_t' has not been declared
__shared_ptr(const __weak_ptr<_Tp, _Lp>& __r, std::nothrow_t)
^~~
C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++/bits/shared_ptr_base.
h: In constructor 'std::__shared_ptr<_Tp, _Lp>::__shared_ptr(const std::__weak_p
tr<_Tp, _Lp>&, int)':
C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++/bits/shared_ptr_base.
h:1353:43: error: 'nothrow' is not a member of 'std'
: _M_refcount(__r._M_refcount, std::nothrow)
^~~~~~~
C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++/bits/shared_ptr_base.
h: In member function 'std::__shared_ptr<_Tp, _Lp> std::__weak_ptr<_Tp, _Lp>::lo
ck() const':
C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++/bits/shared_ptr_base.
h:1687:60: error: 'nothrow' is not a member of 'std'
{ return __shared_ptr<element_type, _Lp>(*this, std::nothrow); }
^~~~~~~
In file included from C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++
/memory:81,
from source2.cpp:3:
C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++/bits/shared_ptr.h: At
global scope:
C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++/bits/shared_ptr.h:367
:44: error: 'std::nothrow_t' has not been declared
shared_ptr(const weak_ptr<_Tp>& __r, std::nothrow_t)
^~~
C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++/bits/shared_ptr.h: In
constructor 'std::shared_ptr<_Tp>::shared_ptr(const std::weak_ptr<_Tp>&, int)':
C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++/bits/shared_ptr.h:368
:37: error: 'nothrow' is not a member of 'std'
: __shared_ptr<_Tp>(__r, std::nothrow) { }
^~~~~~~
C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++/bits/shared_ptr.h: In
member function 'std::shared_ptr<_Tp> std::weak_ptr<_Tp>::lock() const':
C:/Strawberry/c/lib/gcc/i686-w64-mingw32/8.3.0/include/c++/bits/shared_ptr.h:599
:44: error: 'nothrow' is not a member of 'std'
{ return shared_ptr<_Tp>(*this, std::nothrow); }
^~~~~~~
but if I change (the right word is add since next line not in the ,t)
#include <new>
to
#include <c++/new>
no more errors, console is silent, and I have a source2.o file on my disk.
C:\sources\perl5\win32>cd ..\t & g++ -c -DWIN32 -DPERL_TEXTMODE_SCRIPTS -DMULTI
PLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-s
trict-aliasing -mms-bitfields -IC:\sources\perl5 -IC:\sources\perl5\lib\CORE -st
d=c++17 source2.cpp & cd ..\win32
C:\sources\perl5\win32>dir ..\t\source2.o
Volume in drive C has no label.
Volume Serial Number is C43E-2B1E
Directory of C:\sources\perl5\t
08/20/2025 05:01 PM 23,187 source2.o
1 File(s) 23,187 bytes
0 Dir(s) 209,645,223,936 bytes free
C:\sources\perl5\win32>
IDK why adding
#include <c++/new>
before
#include <iostream>
#include <memory>
made it work.
Putting in #include <c++/new> and #include <new> were random ideas found and played around with by grepping GCC's headers. IDK y they worked, and I have no comment if adding #include <c++/new> is a correct fix or not. C++ isn't my specialty.
Expected behavior
A GCC released in Feb 2019 is still supported by p5p.
Perl configuration
C:\sources\perl5\win32>..\perl -I..\lib -V
Summary of my perl5 (revision 5 version 43 subversion 2) configuration:
Derived from: ab823bcb5a9b91d0a9109770da317bde4f6c2db5
Platform:
osname=MSWin32
osvers=6.1.7601
archname=MSWin32-x86-multi-thread
uname=''
config_args='undef'
hint=recommended
useposix=true
d_sigaction=undef
useithreads=define
usemultiplicity=define
use64bitint=undef
use64bitall=undef
uselongdouble=undef
usemymalloc=n
default_inc_excludes_dot=define
Compiler:
cc='gcc'
ccflags ='-std=c99 -DWIN32 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMP
LICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mm
s-bitfields'
optimize='-Os'
cppflags='-DWIN32'
ccversion=''
gccversion='8.3.0'
gccosandvers=''
intsize=4
longsize=4
ptrsize=4
doublesize=8
byteorder=1234
doublekind=3
d_longlong=define
longlongsize=8
d_longdbl=define
longdblsize=12
longdblkind=3
ivtype='long'
ivsize=4
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:\Strawberry\c\lib" -L"C:\Strawberry\c
\i686-w64-mingw32\lib" -L"C:\Strawberry\c\lib\gcc\i686-w64-mingw32\8.3.0"'
libpth=C:\Strawberry\c\lib C:\Strawberry\c\i686-w64-mingw32\lib C:\Strawberr
y\c\lib\gcc\i686-w64-mingw32\8.3.0
libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi3
2 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversio
n -lodbc32 -lodbccp32 -lcomctl32
perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladv
api32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lve
rsion -lodbc32 -lodbccp32 -lcomctl32
libc=-lmsvcrt
so=dll
useshrplib=true
libperl=libperl543.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:\Strawberry\c\lib" -L"C:\Str
awberry\c\i686-w64-mingw32\lib" -L"C:\Strawberry\c\lib\gcc\i686-w64-mingw32\8.3.
0"'
Characteristics of this binary (from libperl):
Compile-time options:
HAS_LONG_DOUBLE
HAS_TIMES
HAVE_INTERP_INTERN
MULTIPLICITY
PERLIO_LAYERS
PERL_COPY_ON_WRITE
PERL_DONT_CREATE_GVSV
PERL_HASH_FUNC_ZAPHOD32
PERL_HASH_USE_SBOX32
PERL_IMPLICIT_SYS
PERL_MALLOC_WRAP
PERL_OP_PARENT
PERL_PRESERVE_IVUV
PERL_USE_SAFE_PUTENV
USE_ITHREADS
USE_LARGE_FILES
USE_LOCALE
USE_LOCALE_COLLATE
USE_LOCALE_CTYPE
USE_LOCALE_NUMERIC
USE_LOCALE_TIME
USE_PERLIO
USE_PERL_ATOF
Locally applied patches:
uncommitted-changes
Built under MSWin32
Compiled at Aug 20 2025 12:24:41
%ENV:
PERL_JSON_BACKEND="Cpanel::JSON::XS"
PERL_YAML_BACKEND="YAML::XS"
@INC:
..\lib
C:/sources/perl5/lib
C:\sources\perl5\win32>