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; }