https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97581

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gcc dot gnu.org

--- Comment #1 from anlauf at gcc dot gnu.org ---
(In reply to David Binderman from comment #0)
> gcc has a new warning, so a problem is found in fortran library.
> 
> libgfortran/intrinsics/random.c:754:37: warning: expression does not compute
> the number of elements in this array; element type is ‘uint64_t’ {aka ‘long
> unsigned int’}, not ‘GFC_INTEGER_4’ {aka ‘int’} [-Wsizeof-array-div]
> 
> Source code is
> 
> #define SZ (sizeof (master_state.s) / sizeof (GFC_INTEGER_4))
> 
> Maybe better code
> 
> #define SZ (sizeof (master_state.s) / sizeof (master_state.s[0]))

No, this would be definitely wrong.

The purpose of RANDOM_SEED is to set/get the internal state of the PRNG in
an array of integers, with the size depending on the kind of the argument.
The function random_seed_i4 uses GFC_INTEGER_4 for that purpose.

If the original code does not make you happy, do you think sth. along

#define SZ (SZU64 * (sizeof (uint64_t) / sizeof (GFC_INTEGER_4)))

would be better?

Reply via email to