This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [patch/rfc] Eliminate char buf[MAX_REGISTER_RAW_SIZE]
- From: Michael Elizabeth Chastain <mec at shout dot net>
- To: ac131313 at redhat dot com, msnyder at redhat dot com
- Cc: gdb-patches at sources dot redhat dot com
- Date: Sat, 1 Feb 2003 11:33:49 -0600
- Subject: Re: [patch/rfc] Eliminate char buf[MAX_REGISTER_RAW_SIZE]
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