[patch/rfc] Eliminate char buf[MAX_REGISTER_RAW_SIZE]
Michael Elizabeth Chastain
mec@shout.net
Sat Feb 1 17:33:00 GMT 2003
Michael Snyder writes:
> Some compilers will not allow a function call in an auto initializer.
I think you are thinking of
static int i = foo (); /* not legal in any C standard that I know */
Rather than
auto int i = foo (); /* been legal since K&R C */
Static and global initializers have to be resolved by link time so they
have to be constants or nearly constant (address expressions like
'&array' or '&function). Auto initializers can be any expression
including function calls. It's been that way since K&R C.
It would take a really deficient compiler to screw that up. I
acknowledge that there is no limit to how messed up a vendor C compiler
can actually be. So I took a quick look at utils.c (at random) to see
if gdb uses this construct anywhere else. And it does:
/* gdb 5.2.1 utils.c */
struct cleanup *
make_cleanup_close (int fd)
{
int *saved_fd = xmalloc (sizeof (fd));
...
}
void
quit (void)
{
struct serial *gdb_stdout_serial = serial_fdopen (1);
...
}
So we are safe on this point.
Michael C
More information about the Gdb-patches
mailing list