This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 07/10] test: evaluate pointers to C99 vla correctly.


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]