Compilation error: G::optional implicit exception-specification 'noexcept'
SMTP email proxy and relay server
Brought to you by:
graeme_walker
Hi, I sucefully compiled the v2.4.1 for OpenWrt and send a PR with the version update https://github.com/openwrt/packages/pull/20035
But when tried to compile the v2.4.1 for TurrisOS which is based on OpenWrt I got the compilation error:
In file included from gstringlist.h:28,
from gstringlist.cpp:22:
goptional.h: In instantiation of 'class G::optional<std::basic_string<char> >':
gstringlist.h:89:42: required from here
goptional.h:66:1: error: function 'G::optional<T>::optional() [with T = std::basic_string<char>]' defaulted on its redeclaration with an exception-specification that differs from the implicit exception-specification 'noexcept'
G::optional<T>::optional() noexcept(noexcept(T()))
^
I'm not a C++ dev but it looks like in the goptional.h we should add or remove noexcept from a constructor.
Maybe for OpenWrt compilation is not that strict.
Could you please fix before my PR will be merged so that TurrisOS won't need for an additional patch?
That's one for the language lawyers, but the code looks correct to me. What is the compiler?
As a workround I would try putting the definition into the declaration, so replacing the semi-colon on line 40 with two curly brackets {} and deleting the stanza around line 65.
Are you taking code from sourceforge subversion? I have previously had a tag for a release and then a 'fixes' branch for this sort of change. Does that work for you?
The compiler is gcc 8.4.0.
The source code is taken from the released tarball here, which is being downloaded while compiling emailrelay for OpenWrt. Your committed change (https://sourceforge.net/p/emailrelay/code/315/) works for Turris OS 6.0, which is using OpenWrt 21.02, while without it was not working.
Thanks!
I made the change and added a semicolon and the error disapperared
===================================================================
diff --git a/branches/V_2_4_1_fixes/src/glib/goptional.h
b/branches/V_2_4_1_fixes/src/glib/goptional.h
--- a/branches/V_2_4_1_fixes/src/glib/goptional.h (revision 315)
+++ b/branches/V_2_4_1_fixes/src/glib/goptional.h (date 1670758431035)
@@ -37,7 +37,7 @@
class G::optional
{
public:
- optional() noexcept(noexcept(T())) {}
+ optional() noexcept(noexcept(T())) {} ;
explicit optional( const T & ) ;
optional( bool has_value , const T & value ) ; // not in std::optional()
void clear() ; // not in std::optional()
But then I got another problem that looks like related to LTO:
arm-openwrt-linux-muslgnueabi-gcc-ar cru libmain.a serviceimp_none.o
servicecontrol_unix.o options.o
/mnt/work/wrt/turris-build/build/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-8.4.0_musl_eabi/lib/gcc/arm-openwrt-linux-muslgnueabi/8.4.0/../../../../arm-openwrt-linux-muslgnueabi/bin/ar:
u' modifier ignored since
D' is the default (see `U')arm-openwrt-linux-muslgnueabi-gcc-ranlib libmain.a
ccache_cxx -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts
-Wno-error=unused-but-set-variable -Wno-error=unused-result
-mfloat-abi=hard
-fmacro-prefix-map=/mnt/work/wrt/turris-build/build/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/emailrelay-2.4.1=emailrelay-2.4.1
-Wformat -Werror=format-security -DPIC -fpic -fstack-protector-strong
-D_FORTIFY_SOURCE=2 -Wl,-z,now -Wl,-z,relro -ffunction-sections
-fdata-sections -flto -Wl,--gc-sections,--as-needed
-L/mnt/work/wrt/turris-build/build/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-8.4.0_musl_eabi/usr/lib
-L/mnt/work/wrt/turris-build/build/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-8.4.0_musl_eabi/lib
-DPIC -fpic -specs=/mnt/work/wrt/turris-build/build/include/hardened-ld-pie.specs
-znow -zrelro -o emailrelay main.o commandline.o configuration.o
legal.o output.o run.o libmain.a ../../src/gpop/libgpop.a
../../src/gsmtp/libgsmtp.a ../../src/gauth/libgauth.a
../../src/gnet/libgnet.a ../../src/gssl/libgssl.a
../../src/glib/libglib.a -lssl -lcrypto
/mnt/work/wrt/turris-build/build/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-8.4.0_musl_eabi/arm-openwrt-linux-muslgnueabi/include/c++/8.4.0/ext/string_conversions.h:
In function '__to_xstring.constprop':
../../../../../staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-8.4.0_musl_eabi/include/fortify/stdio.h:70:28:
error: inlining failed in call to always_inline 'vsnprintf': function
body can be overwritten at link time
_FORTIFY_FN(vsnprintf) int vsnprintf(char __s, size_t __n, const char __f,
^
/mnt/work/wrt/turris-build/build/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-8.4.0_musl_eabi/arm-openwrt-linux-muslgnueabi/include/c++/8.4.0/ext/string_conversions.h:111:32:
note: called from here
const int __len = __convf(__s, __n, __fmt, __args);
^
lto-wrapper: fatal error:
/mnt/work/wrt/turris-build/build/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-8.4.0_musl_eabi/bin/arm-openwrt-linux-muslgnueabi-g++
returned 1 exit status
compilation terminated.
/mnt/work/wrt/turris-build/build/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-8.4.0_musl_eabi/lib/gcc/arm-openwrt-linux-muslgnueabi/8.4.0/../../../../arm-openwrt-linux-muslgnueabi/bin/ld:
error: lto-wrapper failed
collect2: error: ld returned 1 exit status
@Josef you probably know how to fix that.
Thank you
On Sun, 11 Dec 2022 at 09:17, Josef Schlehofer
pepes@users.sourceforge.net wrote:
--
Sergey Ponomarev,
stokito.com
Related
Bugs:
#52FWIW there should be no need for the semi-colon after the curlies and it might get flagged up as unnecessary by some static code analysis tools.
The emailrelay code does not use sprintf etc directly, so I can't help on that one.
oh, yes, the ; is not needed. I just compiled it incorrectly first time.
Speaking about the other error it looks like a compiler error
https://gitlab.alpinelinux.org/alpine/aports/-/issues/8626
On Sun, 11 Dec 2022 at 17:03, Graeme Walker
graeme_walker@users.sourceforge.net wrote:
--
Sergey Ponomarev,
stokito.com
Related
Bugs:
#52