[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
4.1.3 gmpxx.h compiler warning
From: |
Procida, Giuliano |
Subject: |
4.1.3 gmpxx.h compiler warning |
Date: |
Wed, 29 Sep 2004 16:30:40 +0100 |
Hi.
One of the mpz_classref constructors discards a const qualifier. The
resulting warnings are quite annoying in a large project. The test case
consists of the gmpxx.h header file alone.
I already know the various ways of suppressing the warning with GCC
options.
Detailed information is at the bottom of this email.
Regards,
Giuliano Procida.
Version
4.1.3, unpatched, compiled locally
(GMP 4.1.4 seems to have the same issue)
Platform
Linux hostname 2.4.21-15.ELhugemem #1 SMP Thu Apr 22 00:09:08 EDT 2004
i686 i686 i386 GNU/Linux
Configuration
CC=.../gcc CXX=.../g++ .../configure --prefix=... ABI=32 --enable-cxx
In this case ABI=32 makes no difference and CC/CXX are GCC 3.4.1 (same
compiler used below).
Source
#include <gmpxx.h>
Commmand
g++ -Wcast-qual -I.../gmp/include -c -o test.o test.cc
Compiler warning
In file included from test.cc:1:
.../include/gmpxx.h: In constructor `__gmp_expr<__gmpz_value,
__gmpzref_value>::__gmp_expr(const __mpz_struct*)':
.../include/gmpxx.h:2430: warning: cast from `const __mpz_struct*' to
`__mpz_struct*' discards qualifiers from pointer target type
Context
gmp.h:
typedef __gmp_const __mpz_struct *mpz_srcptr;
typedef __mpz_struct *mpz_ptr;
gmpxx.h:
template <>
class __gmp_expr<__gmpz_value, __gmpzref_value>
{
friend class __gmp_expr<__gmpq_value, __gmpq_value>;
private:
mpz_ptr ref;
__gmp_expr();
// __gmp_expr(const __gmp_expr &);
__gmp_expr(mpz_ptr z) : ref(z) { }
__gmp_expr(mpz_srcptr z) : ref((mpz_ptr) z) { } // << cast here
public:
unsigned long int get_prec() const { return mpf_get_default_prec(); }
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- 4.1.3 gmpxx.h compiler warning,
Procida, Giuliano <=