Re: cxxtools-2.2.1 fails to compile on rawhide with gcc11 with /usr/include/c++/11/string_view:98:21: error: static assertion failed
On 03/02/21 12:24 -, Martin Gansser wrote: you mean, this part of the patch can be removed ? @@ -336,14 +331,14 @@ inline char_traits::char_type* char_traits::move(char_type* s1, const char_type* s2, int_type n) { -return (cxxtools::Char*)std::memmove(s1, s2, n * sizeof(cxxtools::Char)); +return static_cast(std::memmove(static_cast(s1), static_cast(s2), n * sizeof(cxxtools::Char))); } inline char_traits::char_type* char_traits::copy(char_type* s1, const char_type* s2, size_t n) { -return (cxxtools::Char*)std::memcpy(s1, s2, n * sizeof(cxxtools::Char)); +return static_cast(std::memcpy(static_cast(s1), static_cast(s2), n * sizeof(cxxtools::Char))); } Yes, I think so. With the operator= removed (or defined as default) the type is trivially copyable, so it's OK to use memmove and memcpy on it. So you shouldn't get any warnings about doing that. ___ devel mailing list -- devel@lists.fedoraproject.org To unsubscribe send an email to devel-le...@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org
Re: cxxtools-2.2.1 fails to compile on rawhide with gcc11 with /usr/include/c++/11/string_view:98:21: error: static assertion failed
you mean, this part of the patch can be removed ? @@ -336,14 +331,14 @@ inline char_traits::char_type* char_traits::move(char_type* s1, const char_type* s2, int_type n) { -return (cxxtools::Char*)std::memmove(s1, s2, n * sizeof(cxxtools::Char)); +return static_cast(std::memmove(static_cast(s1), static_cast(s2), n * sizeof(cxxtools::Char))); } inline char_traits::char_type* char_traits::copy(char_type* s1, const char_type* s2, size_t n) { -return (cxxtools::Char*)std::memcpy(s1, s2, n * sizeof(cxxtools::Char)); +return static_cast(std::memcpy(static_cast(s1), static_cast(s2), n * sizeof(cxxtools::Char))); } ___ devel mailing list -- devel@lists.fedoraproject.org To unsubscribe send an email to devel-le...@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org
Re: cxxtools-2.2.1 fails to compile on rawhide with gcc11 with /usr/include/c++/11/string_view:98:21: error: static assertion failed
On 31/01/21 10:00 -, Martin Gansser wrote: The issue has now been resolved with this patch: +++ include/cxxtools/char.h 2021-01-30 18:28:23.87739 +0100 @@ -68,9 +68,7 @@ typedef int32_t value_type; //! Constructs a character with a value of 0. -Char() -: _value(0) -{} +Char() = default; //! Constructs a character using the given char as base for the character value. Char(char ch) @@ -114,9 +112,6 @@ return Char(0); } -Char& operator=(const Char& ch) -{ _value = ch._value; return *this; } - Ah, I was looking at the upstream code which has already removed that. /** * @brief Returns the internal value (unsigned 32 bits) of this character. * @return The 32-bit-value of this character. @@ -336,14 +331,14 @@ inline char_traits::char_type* char_traits::move(char_type* s1, const char_type* s2, int_type n) { -return (cxxtools::Char*)std::memmove(s1, s2, n * sizeof(cxxtools::Char)); +return static_cast(std::memmove(static_cast(s1), static_cast(s2), n * sizeof(cxxtools::Char))); } inline char_traits::char_type* char_traits::copy(char_type* s1, const char_type* s2, size_t n) { -return (cxxtools::Char*)std::memcpy(s1, s2, n * sizeof(cxxtools::Char)); +return static_cast(std::memcpy(static_cast(s1), static_cast(s2), n * sizeof(cxxtools::Char))); These changes seem unnecessary, and would only hide bugs. After removing the non-trivial operator= there should be no more warning about using memmove and memcpy on Char objects. ___ devel mailing list -- devel@lists.fedoraproject.org To unsubscribe send an email to devel-le...@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org
Re: cxxtools-2.2.1 fails to compile on rawhide with gcc11 with /usr/include/c++/11/string_view:98:21: error: static assertion failed
The issue has now been resolved with this patch: +++ include/cxxtools/char.h 2021-01-30 18:28:23.87739 +0100 @@ -68,9 +68,7 @@ typedef int32_t value_type; //! Constructs a character with a value of 0. -Char() -: _value(0) -{} +Char() = default; //! Constructs a character using the given char as base for the character value. Char(char ch) @@ -114,9 +112,6 @@ return Char(0); } -Char& operator=(const Char& ch) -{ _value = ch._value; return *this; } - /** * @brief Returns the internal value (unsigned 32 bits) of this character. * @return The 32-bit-value of this character. @@ -336,14 +331,14 @@ inline char_traits::char_type* char_traits::move(char_type* s1, const char_type* s2, int_type n) { -return (cxxtools::Char*)std::memmove(s1, s2, n * sizeof(cxxtools::Char)); +return static_cast(std::memmove(static_cast(s1), static_cast(s2), n * sizeof(cxxtools::Char))); } inline char_traits::char_type* char_traits::copy(char_type* s1, const char_type* s2, size_t n) { -return (cxxtools::Char*)std::memcpy(s1, s2, n * sizeof(cxxtools::Char)); +return static_cast(std::memcpy(static_cast(s1), static_cast(s2), n * sizeof(cxxtools::Char))); } Regards Martin ___ devel mailing list -- devel@lists.fedoraproject.org To unsubscribe send an email to devel-le...@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org
Re: cxxtools-2.2.1 fails to compile on rawhide with gcc11 with /usr/include/c++/11/string_view:98:21: error: static assertion failed
On 29/01/21 09:16 -, Martin Gansser wrote: Hi, i am trying to compile cxxtools 2.2.1 [1] on Fedora 34 with gcc11 but this fails with following error messages [2] on Fedora build server. make[2]: Entering directory '/builddir/build/BUILD/cxxtools-2.2.1/src' /bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I../src -I../include -I../include -Wno-long-long -Wall -pedantic -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -c -o settingswriter.lo settingswriter.cpp libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../src -I../include -I../include -Wno-long-long -Wall -pedantic -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -c settingswriter.cpp -fPIC -DPIC -o .libs/settingswriter.o In file included from settingswriter.h:31, from settingswriter.cpp:28: ../include/cxxtools/char.h: In static member function 'static std::char_traits::char_type* std::char_traits::move(std::char_traits::char_type*, const char_type*, std::char_traits::int_type)': ../include/cxxtools/char.h:337:80: warning: 'void* memmove(void*, const void*, size_t)' writing to an object of type 'std::char_traits::char_type' {aka 'class cxxtools::Char'} with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess] 337 | return (cxxtools::Char*)std::memmove(s1, s2, n * sizeof(cxxtools::Char)); | ^ In file included from settingswriter.h:31, from settingswriter.cpp:28: ../include/cxxtools/char.h:65:11: note: 'std::char_traits::char_type' {aka 'class cxxtools::Char'} declared here 65 | class Char | ^~~~ In file included from settingswriter.h:31, from settingswriter.cpp:28: ../include/cxxtools/char.h: In static member function 'static std::char_traits::char_type* std::char_traits::copy(std::char_traits::char_type*, const char_type*, std::size_t)': ../include/cxxtools/char.h:344:79: warning: 'void* memcpy(void*, const void*, size_t)' writing to an object of type 'std::char_traits::char_type' {aka 'class cxxtools::Char'} with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess] 344 | return (cxxtools::Char*)std::memcpy(s1, s2, n * sizeof(cxxtools::Char)); | ^ This warning is surprising. The type should have a trivial copy assignment operator. In file included from settingswriter.h:31, from settingswriter.cpp:28: ../include/cxxtools/char.h:65:11: note: 'std::char_traits::char_type' {aka 'class cxxtools::Char'} declared here 65 | class Char | ^~~~ In file included from /usr/include/c++/11/bits/basic_string.h:48, from /usr/include/c++/11/string:55, from ../include/cxxtools/char.h:32, from settingswriter.h:31, from settingswriter.cpp:28: /usr/include/c++/11/string_view: In instantiation of 'class std::basic_string_view >': settingswriter.cpp:42:26: required from here /usr/include/c++/11/string_view:98:21: error: static assertion failed 98 | static_assert(is_trivial_v<_CharT> && is_standard_layout_v<_CharT>); | ^~~~ /usr/include/c++/11/string_view:98:21: note: 'std::is_trivial_v' evaluates to false With the patch below the class should be trivial. However, if it has a non-trivial copy assignment operator, that would explain why it's not trivial. Why is the copy assignment operator not trivial? That's what you need to check. make[2]: *** [Makefile:740: settingswriter.lo] Error 1 [1] https://martinkg.fedorapeople.org/ErrorReports/cxxtools-2.2.1-25.fc33.src.rpm [2] https://koji.fedoraproject.org/koji/taskinfo?taskID=60804463 I use the following patch for gcc11: --- include/cxxtools/char.h.orig2021-01-28 10:15:36.017763265 +0100 +++ include/cxxtools/char.h 2021-01-28 10:16:14.833762026 +0100 @@ -68,9 +68,7 @@ typedef int32_t value_type; //! Constructs a character with a value of 0. -Char() -: _value(0) -{} +Char() = default; //! Constructs a character using the given char as base for
cxxtools-2.2.1 fails to compile on rawhide with gcc11 with /usr/include/c++/11/string_view:98:21: error: static assertion failed
Hi, i am trying to compile cxxtools 2.2.1 [1] on Fedora 34 with gcc11 but this fails with following error messages [2] on Fedora build server. make[2]: Entering directory '/builddir/build/BUILD/cxxtools-2.2.1/src' /bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I../src -I../include -I../include -Wno-long-long -Wall -pedantic -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -c -o settingswriter.lo settingswriter.cpp libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../src -I../include -I../include -Wno-long-long -Wall -pedantic -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -c settingswriter.cpp -fPIC -DPIC -o .libs/settingswriter.o In file included from settingswriter.h:31, from settingswriter.cpp:28: ../include/cxxtools/char.h: In static member function 'static std::char_traits::char_type* std::char_traits::move(std::char_traits::char_type*, const char_type*, std::char_traits::int_type)': ../include/cxxtools/char.h:337:80: warning: 'void* memmove(void*, const void*, size_t)' writing to an object of type 'std::char_traits::char_type' {aka 'class cxxtools::Char'} with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess] 337 | return (cxxtools::Char*)std::memmove(s1, s2, n * sizeof(cxxtools::Char)); | ^ In file included from settingswriter.h:31, from settingswriter.cpp:28: ../include/cxxtools/char.h:65:11: note: 'std::char_traits::char_type' {aka 'class cxxtools::Char'} declared here 65 | class Char | ^~~~ In file included from settingswriter.h:31, from settingswriter.cpp:28: ../include/cxxtools/char.h: In static member function 'static std::char_traits::char_type* std::char_traits::copy(std::char_traits::char_type*, const char_type*, std::size_t)': ../include/cxxtools/char.h:344:79: warning: 'void* memcpy(void*, const void*, size_t)' writing to an object of type 'std::char_traits::char_type' {aka 'class cxxtools::Char'} with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess] 344 | return (cxxtools::Char*)std::memcpy(s1, s2, n * sizeof(cxxtools::Char)); | ^ In file included from settingswriter.h:31, from settingswriter.cpp:28: ../include/cxxtools/char.h:65:11: note: 'std::char_traits::char_type' {aka 'class cxxtools::Char'} declared here 65 | class Char | ^~~~ In file included from /usr/include/c++/11/bits/basic_string.h:48, from /usr/include/c++/11/string:55, from ../include/cxxtools/char.h:32, from settingswriter.h:31, from settingswriter.cpp:28: /usr/include/c++/11/string_view: In instantiation of 'class std::basic_string_view >': settingswriter.cpp:42:26: required from here /usr/include/c++/11/string_view:98:21: error: static assertion failed 98 | static_assert(is_trivial_v<_CharT> && is_standard_layout_v<_CharT>); | ^~~~ /usr/include/c++/11/string_view:98:21: note: 'std::is_trivial_v' evaluates to false make[2]: *** [Makefile:740: settingswriter.lo] Error 1 [1] https://martinkg.fedorapeople.org/ErrorReports/cxxtools-2.2.1-25.fc33.src.rpm [2] https://koji.fedoraproject.org/koji/taskinfo?taskID=60804463 I use the following patch for gcc11: --- include/cxxtools/char.h.orig2021-01-28 10:15:36.017763265 +0100 +++ include/cxxtools/char.h 2021-01-28 10:16:14.833762026 +0100 @@ -68,9 +68,7 @@ typedef int32_t value_type; //! Constructs a character with a value of 0. -Char() -: _value(0) -{} +Char() = default; //! Constructs a character using the given char as base for the character value. Char(char ch) --- src/char.cpp.orig 2021-01-29 09:50:47.876669852 +0100 +++ src/char.cpp2021-01-29 09:51:37.747675779 +0100 @@ -140,7 +140,7 @@ cxxtools::Char ctype::do_widen(char ch) const { -return cxxtools::Char(ch); +return cxxtools::Char(static_cast(ch)); } but this patch didn't