* Unused variables in testsuite
@ 2006-04-28 14:45 Christophe LYON
2006-04-28 15:11 ` Daniel Jacobowitz
0 siblings, 1 reply; 2+ messages in thread
From: Christophe LYON @ 2006-04-28 14:45 UTC (permalink / raw)
To: gdb
Hi all,
While fixing our compiler, I came across strange tests in the GDB
testsuite: in some source files, some variables are defined but not used
by the code, but are references in the .exp.
Is there anywhere a requirement that the compiler should allocate unused
variable under -O0 ?
For instance, consider the test in gdb.cp/m-static.cc , m-static.h,
m-static1.cc.
You can see that in main() one defines "test4" which is not used, thus
need not be allocated. Then, using "print test4.elsewhere" under GDB
fails. [note that in this case the default (empty) constructor for test4
has no side effects, thus test4 can be eliminated safely]
In the same way, in gdb.mi/var-cmd.c , mi-var-display.exp, you can see
that function do_special_tests() defines several variables (eg 'u') and
does not use them, while the .exp file tries to "-var-create u * u".
I modified these tests so that the variables are used, and they now pass
with our compiler.
May I submit this small patch, or is there a requirement on GCC to
allocate even unused variables in -O0? (our compiler is not GCC)
Thanks,
Christophe.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Unused variables in testsuite
2006-04-28 14:45 Unused variables in testsuite Christophe LYON
@ 2006-04-28 15:11 ` Daniel Jacobowitz
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Jacobowitz @ 2006-04-28 15:11 UTC (permalink / raw)
To: Christophe LYON; +Cc: gdb
On Fri, Apr 28, 2006 at 04:38:56PM +0200, Christophe LYON wrote:
> Is there anywhere a requirement that the compiler should allocate unused
> variable under -O0 ?
This sort of requirement is never documented anywhere; it's just a
question of common practice. Which in practice means GCC, until
someone is interested in making it more portable.
> For instance, consider the test in gdb.cp/m-static.cc , m-static.h,
> m-static1.cc.
> You can see that in main() one defines "test4" which is not used, thus
> need not be allocated. Then, using "print test4.elsewhere" under GDB
> fails. [note that in this case the default (empty) constructor for test4
> has no side effects, thus test4 can be eliminated safely]
>
> In the same way, in gdb.mi/var-cmd.c , mi-var-display.exp, you can see
> that function do_special_tests() defines several variables (eg 'u') and
> does not use them, while the .exp file tries to "-var-create u * u".
>
> I modified these tests so that the variables are used, and they now pass
> with our compiler.
>
> May I submit this small patch, or is there a requirement on GCC to
> allocate even unused variables in -O0? (our compiler is not GCC)
I'd recommend submitting it. We (CodeSourcery) have been slowly
submitting patches to allow the testsuite to run with yet another
compiler (ARM's); we hadn't gotten to this one yet, but I think it's in
there somewhere, because I remember having to modify m-static*.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-04-28 14:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-28 14:45 Unused variables in testsuite Christophe LYON
2006-04-28 15:11 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox