This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 07/10] test: evaluate pointers to C99 vla correctly.
- From: Tom Tromey <tromey at redhat dot com>
- To: Sanimir Agovic <sanimir dot agovic at intel dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 07 Nov 2013 13:55:56 -0700
- Subject: Re: [PATCH 07/10] test: evaluate pointers to C99 vla correctly.
- Authentication-results: sourceware.org; auth=none
- References: <1382366424-21010-1-git-send-email-sanimir dot agovic at intel dot com> <1382366424-21010-8-git-send-email-sanimir dot agovic at intel dot com>
>>>>> "Sanimir" == Sanimir Agovic <sanimir.agovic@intel.com> writes:
Sanimir> +void
Sanimir> +foo (int n, int vla_ptr[n])
Sanimir> +{
Sanimir> + return; /* foo_bp */
Sanimir> +}
Sanimir> +gdb_test "print vla_ptr" "\\\(int \\\*\\\) $hex" "print vla_ptr (foo)"
Sanimir> +gdb_test "print *vla_ptr" "\\$\\d+ = 2" "print *vla_ptr (foo)"
This seems odd to me.
I suppose right now gcc claims that 'vla_ptr' has type 'int *'.
But I don't see why that is necessarily so. Are compilers required to
declare this parameter as an "int *" and not "int[n]"?
That is, this test seems dependent on a compiler quirk.
The second test could maybe be rephrased as "print vla_ptr\[0\]" and
have a well-defined meaning across different styles of DWARF.
Sanimir> +gdb_test "print *vla_ptr" "\\$\\d+ = \\\{2, 3, 4, 5, 6\\\}" "print *vla_ptr (vla_func)"
Sanimir> +gdb_test "print sizeof(*vla_ptr)" "\\$\\d+ = 20" "print sizeof(*vla_ptr) (vla_func)"
Printing plain old "vla" would not be amiss.
Perhaps also reasonable would be a "VLA of typedefs" test like:
typedef int something;
something svla[n];
...
Tom