https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108875
Bug ID: 108875
Summary: Possible wrong error message
Product: gcc
Version: 12.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: jankowski938 at gmail dot com
Target Milestone: ---
If the size of the integer differs from the function pointer size gcc emits
"error: initializer element is not constant". I think it is not the correct one
in this case.
Example code:
#define STACK_START 0x2000000
void reset_handler(void);
const uint64_t vector_table[] =
{
STACK_START,
(uint64_t)&reset_handler
};
void rest_handler(void)
{
}
It will compile for targets where inter type size is the same as the size of
the function pointer. Examples below:
godbolt.org/z/3cj97YzTd and godbolt.org/z/16YoK433r and godbolt.org/z/YoP9bx86a