* [msys+mingw] build error [-Werror=uninitialized]
@ 2012-03-16 1:56 asmwarrior
2012-03-16 7:26 ` Yao Qi
0 siblings, 1 reply; 7+ messages in thread
From: asmwarrior @ 2012-03-16 1:56 UTC (permalink / raw)
To: gdb-patches
I see the build error in the latest cvs:
mingw32-gcc -g -O2 -D__USE_MINGW_ACCESS -I. -I../../gdb/gdb -I../../gdb/gdb/common -I../../gdb/gdb/config -DLOCALEDIR="\"/mingw/share/locale\"" -DHAVE_CONFIG_H -I../../gdb/gdb/../include/opcode -I../../gdb/gdb/../opcodes/.. -I../../gdb/gdb/../readline/.. -I../bfd -I../../gdb/gdb/../bfd -I../../gdb/gdb/../include -I../libdecnumber -I../../gdb/gdb/../libdecnumber -I../../gdb/gdb/gnulib -Ignulib -IE:/code/python272/include -IE:/code/python272/include -Wall -Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral -Wno-pointer-sign -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wmissing-prototypes -Wno-format -Werror -c -o gnu-v3-abi.o -MT gnu-v3-abi.o -MMD -MP -MF .deps/gnu-v3-abi.Tpo ../../gdb/gdb/gnu-v3-abi.c
../../gdb/gdb/gnu-v3-abi.c: In function 'print_one_vtable.isra.2':
../../gdb/gdb/gnu-v3-abi.c:892:33: error: 'addr' may be used uninitialized in this function [-Werror=uninitialized]
cc1.exe: all warnings being treated as errors
make[2]: *** [gnu-v3-abi.o] Error 1
So, I think it can be quickly fixed by using:
CORE_ADDR addr = 0;
Is this correct? I see the addr is used in the try catch block:
TRY_CATCH (ex, RETURN_MASK_ERROR)
{
addr = value_as_address (vfn);
}
if (ex.reason < 0)
printf_filtered (_("<error: %s>"), ex.message);
else
print_function_pointer_address (gdbarch, addr, gdb_stdout,
opts->addressprint);
Not sure why it still report such error.
Yuanhui Zhang
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [msys+mingw] build error [-Werror=uninitialized]
2012-03-16 1:56 [msys+mingw] build error [-Werror=uninitialized] asmwarrior
@ 2012-03-16 7:26 ` Yao Qi
2012-03-16 7:31 ` asmwarrior
0 siblings, 1 reply; 7+ messages in thread
From: Yao Qi @ 2012-03-16 7:26 UTC (permalink / raw)
To: asmwarrior; +Cc: gdb-patches
On 03/16/2012 09:56 AM, asmwarrior wrote:
> I see the build error in the latest cvs:
>
> mingw32-gcc -g -O2 -D__USE_MINGW_ACCESS -I. -I../../gdb/gdb
> -I../../gdb/gdb/common -I../../gdb/gdb/config
> -DLOCALEDIR="\"/mingw/share/locale\"" -DHAVE_CONFIG_H
> -I../../gdb/gdb/../include/opcode -I../../gdb/gdb/../opcodes/..
> -I../../gdb/gdb/../readline/.. -I../bfd -I../../gdb/gdb/../bfd
> -I../../gdb/gdb/../include -I../libdecnumber
> -I../../gdb/gdb/../libdecnumber -I../../gdb/gdb/gnulib -Ignulib
> -IE:/code/python272/include -IE:/code/python272/include -Wall
> -Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral
> -Wno-pointer-sign -Wno-unused -Wunused-value -Wunused-function
> -Wno-switch -Wno-char-subscripts -Wmissing-prototypes -Wno-format
> -Werror -c -o gnu-v3-abi.o -MT gnu-v3-abi.o -MMD -MP -MF
> .deps/gnu-v3-abi.Tpo ../../gdb/gdb/gnu-v3-abi.c
> ../../gdb/gdb/gnu-v3-abi.c: In function 'print_one_vtable.isra.2':
> ../../gdb/gdb/gnu-v3-abi.c:892:33: error: 'addr' may be used
> uninitialized in this function [-Werror=uninitialized]
> cc1.exe: all warnings being treated as errors
> make[2]: *** [gnu-v3-abi.o] Error 1
I get the same error when building gdb on x86_64-linux.
>
> So, I think it can be quickly fixed by using:
> CORE_ADDR addr = 0;
>
Yes, this fixes the build error I got.
> Is this correct? I see the addr is used in the try catch block:
>
> TRY_CATCH (ex, RETURN_MASK_ERROR)
> {
> addr = value_as_address (vfn);
> }
> if (ex.reason < 0)
> printf_filtered (_("<error: %s>"), ex.message);
> else
> print_function_pointer_address (gdbarch, addr, gdb_stdout,
> opts->addressprint);
>
> Not sure why it still report such error.
I didn't see any other errors. What error did you see even after you
setting `addr' to 0?
--
Yao (é½å°§)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [msys+mingw] build error [-Werror=uninitialized]
2012-03-16 7:26 ` Yao Qi
@ 2012-03-16 7:31 ` asmwarrior
2012-03-16 7:45 ` Yao Qi
0 siblings, 1 reply; 7+ messages in thread
From: asmwarrior @ 2012-03-16 7:31 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
On 2012-3-16 15:24, Yao Qi wrote:
> I didn't see any other errors. What error did you see even after you
> setting `addr' to 0?
See:
TRY_CATCH (ex, RETURN_MASK_ERROR)
{
addr = value_as_address (vfn);
}
Which means addr is set before passed to print_function_pointer_address() call.
So I'm not sure why gcc report such warning.
Yuanhui Zhang
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [msys+mingw] build error [-Werror=uninitialized]
2012-03-16 7:31 ` asmwarrior
@ 2012-03-16 7:45 ` Yao Qi
2012-03-16 8:19 ` [commit] " Jan Kratochvil
0 siblings, 1 reply; 7+ messages in thread
From: Yao Qi @ 2012-03-16 7:45 UTC (permalink / raw)
To: asmwarrior; +Cc: gdb-patches
On 03/16/2012 03:31 PM, asmwarrior wrote:
> TRY_CATCH (ex, RETURN_MASK_ERROR)
> {
> addr = value_as_address (vfn);
> }
> Which means addr is set before passed to print_function_pointer_address() call.
>
> So I'm not sure why gcc report such warning.
No idea on this. Patch below fixes the problem on my box.
--
Yao (é½å°§)
2012-03-16 Yao Qi <yao@codesourcery.com>
index 0ba6ab5..5bfabe3 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -870,7 +870,7 @@ print_one_vtable (struct gdbarch *gdbarch, struct
value *value,
for (i = 0; i <= max_voffset; ++i)
{
struct value *vfn;
- CORE_ADDR addr;
+ CORE_ADDR addr = 0;
volatile struct gdb_exception ex;
printf_filtered ("[%d]: ", i);
^ permalink raw reply [flat|nested] 7+ messages in thread
* [commit] [msys+mingw] build error [-Werror=uninitialized]
2012-03-16 7:45 ` Yao Qi
@ 2012-03-16 8:19 ` Jan Kratochvil
2012-03-16 8:23 ` asmwarrior
0 siblings, 1 reply; 7+ messages in thread
From: Jan Kratochvil @ 2012-03-16 8:19 UTC (permalink / raw)
To: Yao Qi; +Cc: asmwarrior, gdb-patches
On Fri, 16 Mar 2012 08:44:37 +0100, Yao Qi wrote:
> On 03/16/2012 03:31 PM, asmwarrior wrote:
> > TRY_CATCH (ex, RETURN_MASK_ERROR)
> > {
> > addr = value_as_address (vfn);
> > }
> > Which means addr is set before passed to print_function_pointer_address() call.
> >
> > So I'm not sure why gcc report such warning.
>
> No idea on this. Patch below fixes the problem on my box.
Added there a comment like in other cases.
This improper warning happens with TRY_CATCH on older gccs.
Thanks,
Jan
http://sourceware.org/ml/gdb-cvs/2012-03/msg00203.html
--- src/gdb/ChangeLog 2012/03/15 18:53:42 1.14016
+++ src/gdb/ChangeLog 2012/03/16 08:18:07 1.14017
@@ -1,3 +1,9 @@
+2012-03-16 Yao Qi <yao@codesourcery.com>
+ Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Fix false compilation warning.
+ * gnu-v3-abi.c (print_one_vtable): Initialize ADDR.
+
2012-03-15 Jonathan Larmour <jifl@eCosCentric.com>
Pedro Alves <pedro@codesourcery.com>
--- src/gdb/gnu-v3-abi.c 2012/03/15 15:43:11 1.70
+++ src/gdb/gnu-v3-abi.c 2012/03/16 08:18:09 1.71
@@ -869,8 +869,9 @@
for (i = 0; i <= max_voffset; ++i)
{
+ /* Initialize it just to avoid a GCC false warning. */
+ CORE_ADDR addr = 0;
struct value *vfn;
- CORE_ADDR addr;
volatile struct gdb_exception ex;
printf_filtered ("[%d]: ", i);
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [commit] [msys+mingw] build error [-Werror=uninitialized]
2012-03-16 8:19 ` [commit] " Jan Kratochvil
@ 2012-03-16 8:23 ` asmwarrior
2012-03-16 14:09 ` asmwarrior
0 siblings, 1 reply; 7+ messages in thread
From: asmwarrior @ 2012-03-16 8:23 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: Yao Qi, gdb-patches
On 2012-3-16 16:19, Jan Kratochvil wrote:
> This improper warning happens with TRY_CATCH on older gccs.
In-fact, I'm using a modern GCC (GCC 4.6.3 under Windows).
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [commit] [msys+mingw] build error [-Werror=uninitialized]
2012-03-16 8:23 ` asmwarrior
@ 2012-03-16 14:09 ` asmwarrior
0 siblings, 0 replies; 7+ messages in thread
From: asmwarrior @ 2012-03-16 14:09 UTC (permalink / raw)
Cc: Jan Kratochvil, Yao Qi, gdb-patches
On 2012-3-16 16:23, asmwarrior wrote:
> On 2012-3-16 16:19, Jan Kratochvil wrote:
>> This improper warning happens with TRY_CATCH on older gccs.
> In-fact, I'm using a modern GCC (GCC 4.6.3 under Windows).
>
I filed a bug report in GCC, see:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52602
Yuanhui Zhang
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-03-16 14:09 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-16 1:56 [msys+mingw] build error [-Werror=uninitialized] asmwarrior
2012-03-16 7:26 ` Yao Qi
2012-03-16 7:31 ` asmwarrior
2012-03-16 7:45 ` Yao Qi
2012-03-16 8:19 ` [commit] " Jan Kratochvil
2012-03-16 8:23 ` asmwarrior
2012-03-16 14:09 ` asmwarrior
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox