Re: 6.2.1 Bus error

2023-02-13 Thread guoyizhang



Hello

I have reported the OS (ArchLinux) which only runs on the x86_64 
machine. For the building issue for GNU MP, I am not familiar with it 
considering that it's just the dependency of amberol (see the GitLab 
issue https://gitlab.gnome.org/World/amberol/-/issues/289)


I already asked the upstream aberol. It states that GMP is being built 
through Cargo in order to use the gmp-mpfr-sys crate 
(https://crates.io/crates/gmp-mpfr-sys), which is a transitive 
dependency of Amberol.



├─gmp-mpfr-sys

├─rug

├─srgb

├─amberol


What other upstream should I report? Arch Linux or Rust crate?

Best regards

Guoyi

On 2023-02-13 06:19, Torbjörn Granlund wrote:

You know, we might do with some more detail on what your experience 
with
GMP might be.  Such as the platform, how you built GMP, what program 
you

ran which triggered a "Bus error".

If something is wrong with, say, a car, do you let the car repair shop
know anything about what the problem is, which car is afflicted, and 
how

to reproduce the problem?  Or do you just say "a car does not work" and
hope they will locate the car and look for some malfunction and then
repair it?


--
Guoyi Zhang
Malacology [1]
Researchgate [2] | OCRID [3]
School of Life Sciences, University of Nottingham
Alternate Email Address

Links:
--
[1] https://malacology.net/
[2] https://www.researchgate.net/profile/Guoyi_Zhang3
[3] https://orcid.org/-0002-3426-9273
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: issue with Microsoft compiler

2023-02-13 Thread sisyphus
Hi Paul,

Before including gmp.h, try:
#pragma warning(disable:4146)

That works for me with compiler version 19.33.31630 for x64.

Cheers,
Rob
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: issue with Microsoft compiler

2023-02-13 Thread Vincent Lefevre
On 2023-02-13 11:54:50 +0100, Marc Glisse wrote:
> Another option, if it is just the one place in gmp.h, would be to replace -X
> with 0-X (or the uglier ~X+1 but that does not seem necessary).

I find 0-X much uglier and it could even more deserve a warning due to
the use of mixed signed-unsigned arithmetic, which can often lead to
unexpected results on some platforms (e.g. whether long = int or not).

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: issue with Microsoft compiler

2023-02-13 Thread Vincent Lefevre
On 2023-02-13 10:20:07 +0100, Marc Glisse wrote:
> On Mon, 13 Feb 2023, Niels Möller wrote:
> > My view is that GMP simply depends on the required semantics of the C
> > specification. And negating mp_limb_t values is something that's done in
> > lots of places. I'm not aware of any workaround that wouldn't result in
> > an annoying amount of clutter.
> 
> I think changing it in public headers (gmp.h, gmpxx.h) is the important
> part, changing it in internal source files is less of an issue.

This is valid C, not even a coding style error, and this is a rather
common use of unsigned types, and sometimes necessary to avoid
undefined behavior (think of "-LONG_MIN", which needs to be done
in unsigned arithmetic, e.g. "- (unsigned long) LONG_MIN", because
-LONG_MIN is not representable as a signed long).

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: issue with Microsoft compiler

2023-02-13 Thread Marc Glisse

On Mon, 13 Feb 2023, Niels Möller wrote:


I got the impression that someone was building GMP with -Werror.


Then I agree that it is their problem.


Getting this by just *using* gmp and including gmp.h is
a different setting with different tradeoffs.

It might make some sense to add something like

 #ifdef _MSC_VER
 # pragma warning(disable:4146)
 #endif

to the installed gmp.h, if that is deemed not too brittle (I don't know
how stable warning numbers are, or if there's some better way). I got
_MCS_VER from a quick look at
https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170

[...]

Is the pragma a documented / recommended way to disable the warning?


The numbers seem stable, and the pragma is advertised by Microsoft 
(https://learn.microsoft.com/en-us/cpp/preprocessor/warning?view=msvc-170) 
and used by many projects 
(https://github.com/CGAL/cgal/blob/master/Number_types/include/CGAL/gmp.h). 
You are supposed to use push/pop as well, though, in a header.


#ifdef _MSC_VER
#  pragma warning(push)
#  pragma warning(disable:4146)
#endif

... code ...

#ifdef _MSC_VER
#  pragma warning(pop)
#endif


Another option, if it is just the one place in gmp.h, would be to replace 
-X with 0-X (or the uglier ~X+1 but that does not seem necessary).


--
Marc Glisse
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: issue with Microsoft compiler

2023-02-13 Thread Niels Möller
Marc Glisse  writes:

> I think changing it in public headers (gmp.h, gmpxx.h) is the
> important part, changing it in internal source files is less of an
> issue.

Good point. I got the impression that someone was building GMP with
-Werror. Getting this by just *using* gmp and including gmp.h is
a different setting with different tradeoffs.

It might make some sense to add something like

  #ifdef _MSC_VER
  # pragma warning(disable:4146)
  #endif

to the installed gmp.h, if that is deemed not too brittle (I don't know
how stable warning numbers are, or if there's some better way). I got
_MCS_VER from a quick look at
https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170

> To be fair, it is often not the user who enables /WX but the Visual
> Studio IDE that enables /SDL by default, which turns some warnings
> that Microsoft deems relevant to security into errors. And Microsoft's
> reply in bug reports is "disable this option if you don't like it".

Is the pragma a documented / recommended way to disable the warning?

The warning would make more sense to me if narrowed to cases where the
result is assigned/used in some signed context where it matters for the
result. E.g., if long is a larger size than int, warning for code like
below seems a lot more reasonable than warning for gmp's use case.

  #include 
  
  int main (int argc, char **argv) {
unsigned int x = 17;
signed long y = -x;
printf("y = %ld\n", y);
return 0;
  }

-- 
Niels Möller. PGP key CB4962D070D77D7FCB8BA36271D8F1FF368C6677.
Internet email is subject to wholesale government surveillance.
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: issue with Microsoft compiler

2023-02-13 Thread Marc Glisse

On Mon, 13 Feb 2023, Niels Möller wrote:


Marc Glisse  writes:


It is certainly possible to avoid the warning, either with a pragma or
with different code, but until now, the policy has been to tell people
to disable this non-sensical behavior in visual studio or use a better
compiler. I don't have a strong opinion here.


My view is that GMP simply depends on the required semantics of the C
specification. And negating mp_limb_t values is something that's done in
lots of places. I'm not aware of any workaround that wouldn't result in
an annoying amount of clutter.


I think changing it in public headers (gmp.h, gmpxx.h) is the important 
part, changing it in internal source files is less of an issue.



And in general, I'd say that whoever decides to add something like
-Werror (turn all warnings into compile errors) to the compiler flags
get's to deal with the work of suppressing any false positives.


To be fair, it is often not the user who enables /WX but the Visual Studio 
IDE that enables /SDL by default, which turns some warnings that Microsoft 
deems relevant to security into errors. And Microsoft's reply in bug 
reports is "disable this option if you don't like it".


--
Marc Glisse
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: issue with Microsoft compiler

2023-02-13 Thread Niels Möller
Marc Glisse  writes:

> It is certainly possible to avoid the warning, either with a pragma or
> with different code, but until now, the policy has been to tell people
> to disable this non-sensical behavior in visual studio or use a better
> compiler. I don't have a strong opinion here.

My view is that GMP simply depends on the required semantics of the C
specification. And negating mp_limb_t values is something that's done in
lots of places. I'm not aware of any workaround that wouldn't result in
an annoying amount of clutter.

And in general, I'd say that whoever decides to add something like
-Werror (turn all warnings into compile errors) to the compiler flags
get's to deal with the work of suppressing any false positives.

Regards,
/Niels

-- 
Niels Möller. PGP key CB4962D070D77D7FCB8BA36271D8F1FF368C6677.
Internet email is subject to wholesale government surveillance.
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: issue with Microsoft compiler

2023-02-13 Thread Marc Glisse

On Mon, 13 Feb 2023, Paul Zimmermann wrote:


  Hi,

someone reported to me the following issue:

  Microsoft (R) C/C++ Optimizing Compiler Version 19.34.31937 for x64

  will not compile line 2230 in gmp.h:

 *__gmp_rp = (- *__gmp_up) & GMP_NUMB_MASK;

  giving error C4146: unary minus operator applied to unsigned type,
  result still unsigned.

Just in case this warning can be avoided.


It has been doing that for a long time, for instance
https://gmplib.org/list-archives/gmp-discuss/2004-September/001332.html

and with some options (like /sdl ?) it is turned into an error. It may be 
that /external:someoption helps disable it without disabling warnings for 
the user's code.


It is certainly possible to avoid the warning, either with a pragma or 
with different code, but until now, the policy has been to tell people to 
disable this non-sensical behavior in visual studio or use a better 
compiler. I don't have a strong opinion here.


--
Marc Glisse
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


issue with Microsoft compiler

2023-02-13 Thread Paul Zimmermann
   Hi,

someone reported to me the following issue:

   Microsoft (R) C/C++ Optimizing Compiler Version 19.34.31937 for x64

   will not compile line 2230 in gmp.h:

  *__gmp_rp = (- *__gmp_up) & GMP_NUMB_MASK;

   giving error C4146: unary minus operator applied to unsigned type, 
   result still unsigned.

Just in case this warning can be avoided.

Best regards,
Paul
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs