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

GCC 14: No match for operator= for Givaro::ZRing<Givaro::Integer> #226

Closed
musicinmybrain opened this issue Jan 20, 2024 · 4 comments
Closed

Comments

@musicinmybrain
Copy link
Contributor

When compiling givaro with GCC 14.0.1 (as now packaged in Fedora Rawhide, the development version of Fedora Linux), I see the following regression:

givaro/givaro/givaro/random-integer.h: In member function 'Givaro::RandomIntegerIterator<_Unsigned, _Exact_Size>& Givaro::RandomIntegerIterator<_Unsigned, _Exact_Size>::operator=(const Givaro::RandomIntegerIterator<_Unsigned, _Exact_Size>&)':
givaro/givaro/givaro/random-integer.h:90:54: error: no match for 'operator=' (operand types are 'Givaro::RandomIntegerIterator<_Unsigned, _Exact_Size>::Integer_Domain' {aka 'Givaro::ZRing<Givaro::Integer>'} and 'const Givaro::RandomIntegerIterator<_Unsigned, _Exact_Size>::Integer_Domain' {aka 'const Givaro::ZRing<Givaro::Integer>'})
   90 |                 const_cast<Integer_Domain&>(_ring)=R._ring;
      |                                                      ^~~~~

I initially observed this with givaro 4.2.0, but I can also reproduce it with current master, a6b3708.

I would be happy to offer a PR, but I haven’t figured out what the correct fix is.

@jgdumas
Copy link
Member

jgdumas commented Jan 24, 2024

Hello, thank you for the report.
I can reproduce this indeed with g++-14.
It is not clear to me yet why this is happening, I'll investigate ...

In the meantime, a simple patch is just to remove the line !
(the line is there for (future) genericity, but for all current usage it just assigns an empty object to another empty object !)

@musicinmybrain
Copy link
Contributor Author

Thanks! The following workaround does appear to be effective:

From 20caba1b549fe46b483f120f8eec6ec4e9f4572d Mon Sep 17 00:00:00 2001
From: "Benjamin A. Beasley" <code@musicinmybrain.net>
Date: Thu, 25 Jan 2024 08:29:17 -0500
Subject: [PATCH] Temporary GCC 14 workaround
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fixes https://github.com/linbox-team/givaro/issues/226 “GCC 14: No match
for operator= for Givaro::ZRing<Givaro::Integer>”

Recommended in
https://github.com/linbox-team/givaro/issues/226#issuecomment-1908853755
---
 src/kernel/integer/random-integer.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/kernel/integer/random-integer.h b/src/kernel/integer/random-integer.h
index f9361d33..ea189a36 100644
--- a/src/kernel/integer/random-integer.h
+++ b/src/kernel/integer/random-integer.h
@@ -87,7 +87,6 @@ namespace Givaro
             if (this != &R) {
                 _bits = R._bits;
                 _integer = R._integer;
-                const_cast<Integer_Domain&>(_ring)=R._ring;
             }
             return *this;
         }
-- 
2.43.0

@jgdumas
Copy link
Member

jgdumas commented Jan 26, 2024

OK. The reference to a singleton element should not be copied.
Patch is thus now within commit b0cf33e.
And givaro compiles completely with g++-14 for me

@jgdumas jgdumas closed this as completed Jan 26, 2024
@musicinmybrain
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants