Created attachment 48882 [details]
Minimal test case
I was surprised to find that my __attribute__((constructor(101))) on a function was not giving it priority over another constructor whose attribute used a higher number. It turns out this was owing to an additional prototype that did not mention the function as a constructor.
This caused a really subtle initialization bug in my code, and was tough to track down. At the least, I would expect a warning when the information is discarded.
I haven't tried on 8.4, but didn't see any relevant changelog entries.
Note that this is not a duplicate of 87592, which is about when the priority is specified multiple times.
$ cat test.c
// comment these for correct behaviour, i.e. 1 then 2
static void do_init1(void);
static void do_init2(void);
static void do_init2(void) __attribute__((constructor(102)));
static void do_init2(void)
static void do_init1(void) __attribute__((constructor(101)));
static void do_init1(void)
$ cc -save-temps test.c -o test
$ grep -B2 init_array test.s
.size do_init2, .-do_init2
.size do_init1, .-do_init1
The attribute's priority argument is being discarded. It should be visible in the section name (".init_array.0101" etc.). If the extra prototypes are removed, the programmer-intended behaviour is restored.