Message ID | 20151102132655.GA10770@linux.vnet.ibm.com |
---|---|
State | New |
Headers | show |
On 11/02/2015 06:26 AM, Dominik Vogt wrote: > The attached patch fixes the annoying warnings generated by > diagnostic_set_last_function. > > Can this be committed? Can you point out what warning you're fixing? Inline or pointer to a build log would be fine. jeff
On Mon, Nov 02, 2015 at 09:57:22AM -0700, Jeff Law wrote: > On 11/02/2015 06:26 AM, Dominik Vogt wrote: > >The attached patch fixes the annoying warnings generated by > >diagnostic_set_last_function. > Can you point out what warning you're fixing? Sure. toplec.c calls diagnostic_set_last_function with a NULL pointer as the second argument, and cp/typeck.c complains about it. Ah, it seems the *current* version of Gcc does not generate the warning, but the old one (4.8.5) I used to compile does. So, it may or may not be worth to apply the patch. -- snip -- unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long \ -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -I. -I. -I../../gcc -I../../gcc/. -I../../gcc/../include -I../../gcc/../libc\ pp/include -I../../gcc/../libdecnumber -I../../gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/../libbacktrace -o trans-mem.o -MT \ trans-mem.o -MMD -MP -MF ./.deps/trans-mem.TPo ../../gcc/trans-mem.c In file included from ../../gcc/toplev.c:42:0: ../../gcc/toplev.c: In function â\200\230void announce_function(tree)â\200\231: ../../gcc/diagnostic.h:202:50: warning: invalid access to non-static data member â\200\230diagnostic_info::x_dataâ\200\231 of NULL object \ [-Winvalid-offsetof] #define diagnostic_info_auxiliary_data(DI) (DI)->x_data ^ ../../gcc/tree-diagnostic.h:28:11: note: in expansion of macro â\200\230diagnostic_info_auxiliary_dataâ\200\231 ((tree) diagnostic_info_auxiliary_data (DI)) ^ ../../gcc/tree-diagnostic.h:47:17: note: in expansion of macro â\200\230diagnostic_abstract_originâ\200\231 = (((DI) && diagnostic_abstract_origin (DI)) \ ^ ../../gcc/toplev.c:233:7: note: in expansion of macro â\200\230diagnostic_set_last_functionâ\200\231 diagnostic_set_last_function (global_dc, (diagnostic_info *) NULL); ^ ../../gcc/diagnostic.h:202:50: warning: (perhaps the â\200\230offsetofâ\200\231 macro was used incorrectly) [-Winvalid-offsetof] #define diagnostic_info_auxiliary_data(DI) (DI)->x_data ^ ../../gcc/tree-diagnostic.h:28:11: note: in expansion of macro â\200\230diagnostic_info_auxiliary_dataâ\200\231 ((tree) diagnostic_info_auxiliary_data (DI)) ^ ../../gcc/tree-diagnostic.h:47:17: note: in expansion of macro â\200\230diagnostic_abstract_originâ\200\231 = (((DI) && diagnostic_abstract_origin (DI)) \ ^ ../../gcc/toplev.c:233:7: note: in expansion of macro â\200\230diagnostic_set_last_functionâ\200\231 diagnostic_set_last_function (global_dc, (diagnostic_info *) NULL); ^ ../../gcc/diagnostic.h:202:50: warning: invalid access to non-static data member â\200\230diagnostic_info::x_dataâ\200\231 of NULL object \ [-Winvalid-offsetof] #define diagnostic_info_auxiliary_data(DI) (DI)->x_data -- snip -- Ciao Dominik ^_^ ^_^
On 11/03/2015 02:57 AM, Dominik Vogt wrote: > On Mon, Nov 02, 2015 at 09:57:22AM -0700, Jeff Law wrote: >> On 11/02/2015 06:26 AM, Dominik Vogt wrote: >>> The attached patch fixes the annoying warnings generated by >>> diagnostic_set_last_function. >> Can you point out what warning you're fixing? > > Sure. toplec.c calls diagnostic_set_last_function with a NULL > pointer as the second argument, and cp/typeck.c complains about > it. Ah, it seems the *current* version of Gcc does not generate > the warning, but the old one (4.8.5) I used to compile does. So, > it may or may not be worth to apply the patch. It looks like that was changed explicitly in 2014 (see the history of g++.dg/abi/offsetof.C). I'm not a C++ expert, but it appears this kind of use is considered OK these days. jeff
On Fri, Nov 06, 2015 at 03:16:37PM -0700, Jeff Law wrote: > On 11/03/2015 02:57 AM, Dominik Vogt wrote: > >On Mon, Nov 02, 2015 at 09:57:22AM -0700, Jeff Law wrote: > >>On 11/02/2015 06:26 AM, Dominik Vogt wrote: > >>>The attached patch fixes the annoying warnings generated by > >>>diagnostic_set_last_function. > >>Can you point out what warning you're fixing? > > > >Sure. toplec.c calls diagnostic_set_last_function with a NULL > >pointer as the second argument, and cp/typeck.c complains about > >it. Ah, it seems the *current* version of Gcc does not generate > >the warning, but the old one (4.8.5) I used to compile does. So, > >it may or may not be worth to apply the patch. > It looks like that was changed explicitly in 2014 (see the history > of g++.dg/abi/offsetof.C). I'm not a C++ expert, but it appears > this kind of use is considered OK these days. All right, if this is the case it's not worth "fixing". I'll keep ignoring gcc-4.8's message. Ciao Dominik ^_^ ^_^
From b09e69bd66f157a2aaf0167b7419f47e9953950a Mon Sep 17 00:00:00 2001 From: Dominik Vogt <vogt@linux.vnet.ibm.com> Date: Mon, 2 Nov 2015 13:58:53 +0100 Subject: [PATCH] Fix warning in tree-diagnostic.h. --- gcc/tree-diagnostic.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gcc/tree-diagnostic.h b/gcc/tree-diagnostic.h index c1cc1c5..60c6f1c 100644 --- a/gcc/tree-diagnostic.h +++ b/gcc/tree-diagnostic.h @@ -43,10 +43,13 @@ along with GCC; see the file COPYING3. If not see /* Remember the current function as being the last one in which we report a diagnostic. */ #define diagnostic_set_last_function(DC, DI) \ - diagnostic_context_auxiliary_data (DC) \ - = (((DI) && diagnostic_abstract_origin (DI)) \ - ? diagnostic_abstract_origin (DI) \ - : current_function_decl) + do { \ + __typeof__ (DI) __x = (DI); \ + diagnostic_context_auxiliary_data (DC) \ + = (((__x) && diagnostic_abstract_origin (__x)) \ + ? diagnostic_abstract_origin (__x) \ + : current_function_decl); \ + } while (0) void diagnostic_report_current_function (diagnostic_context *, diagnostic_info *); -- 2.3.0