parameter type of -frandom-seed

Martin Sebor msebor@gmail.com
Tue Aug 25 23:42:00 GMT 2015


On 08/25/2015 10:48 AM, Stephan Gatzka wrote:
> Hi!
>
> I'm a bit confused about the parameter I have to deliver to -frandom
> -seed.
>
> My manual page states it must be a number, others say it's a string.
>
> If I browse through the sources of gcc, it's also not not obvious to me.
>
> https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/common.opt;hb=HEAD
>
> https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/po/de.po;hb=HEAD
>
> So what's the correct parameter ffor -frandom-seed? A number
> (decimal/hex) or a string?

According to the online manual for the latest GCC it's supposed to
be a non-negative number:

   $ gcc -v --help 2>&1 | grep random-seed
   -frandom-seed               This switch lacks documentation
   -frandom-seed=<number>      Make compile reproducible using <number>

but it looks like there's a bug in the option's specification that
prevents invalid (non-numeric) arguments from being diagnosed, making
GCC accept anything (including negative numbers).

The otherwise untested patch below fixes it for me and makes GCC
accept only non-negative numbers.

A bug should probably be filed for this.

Martin

diff --git a/gcc/common.opt b/gcc/common.opt
index 4dcd518..4776d1f 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1868,7 +1868,7 @@ frandom-seed
  Common Var(common_deferred_options) Defer

  frandom-seed=
-Common Joined RejectNegative Var(common_deferred_options) Defer
+Common Joined RejectNegative UInteger Var(common_deferred_options) Defer
  -frandom-seed=<number> Make compile reproducible using <number>

  ; This switch causes the command line that was used to create an



More information about the Gcc-help mailing list