public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug driver/61868] New: -frandom-seed always results in random_seed of 0
@ 2014-07-21 13:23 bmei at broadcom dot com
2014-07-29 11:25 ` [Bug lto/61868] " bmei at broadcom dot com
2014-07-31 8:57 ` bmei at broadcom dot com
0 siblings, 2 replies; 3+ messages in thread
From: bmei at broadcom dot com @ 2014-07-21 13:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61868
Bug ID: 61868
Summary: -frandom-seed always results in random_seed of 0
Product: gcc
Version: 4.10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: driver
Assignee: unassigned at gcc dot gnu.org
Reporter: bmei at broadcom dot com
Compile any simple file with -frandom-seed and -flto option.
#include <stdio.h>
extern int foo (int);
int bar (int a)
{
return a * 5;
}
int main ()
{
printf("%d\n", foo (100));
return 0;
}
~/scratch/install-x86/bin/gcc tst2.c -flto -c -frandom-seed=12345
objdump -D tst2.o|less
You can see all the lto section has suffix of 0 instead of the random_seed
specified.
<.gnu.lto_.inline.0>
This is because of the following code in toplev.c. If flag_random_seed is true,
then init_random_seed is not called in get_random_seed despite the piece of
code trying to generate random_seed if flag_random_seed is true.
static void
init_random_seed (void)
{
if (flag_random_seed)
{
char *endp;
/* When the driver passed in a hex number don't crc it again */
random_seed = strtoul (flag_random_seed, &endp, 0);
if (!(endp > flag_random_seed && *endp == 0))
random_seed = crc32_string (0, flag_random_seed);
}
else if (!random_seed)
random_seed = local_tick ^ getpid (); /* Old racey fallback method */
}
/* Obtain the random_seed. Unless NOINIT, initialize it if
it's not provided in the command line. */
HOST_WIDE_INT
get_random_seed (bool noinit)
{
if (!flag_random_seed && !noinit)
init_random_seed ();
return random_seed;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-07-31 8:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-21 13:23 [Bug driver/61868] New: -frandom-seed always results in random_seed of 0 bmei at broadcom dot com
2014-07-29 11:25 ` [Bug lto/61868] " bmei at broadcom dot com
2014-07-31 8:57 ` bmei at broadcom dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).