This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug c/84293] New: system-header macro expansion location gives unexpected warning


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84293

            Bug ID: 84293
           Summary: system-header macro expansion location gives
                    unexpected warning
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nathan at gcc dot gnu.org
  Target Milestone: ---

Created attachment 43379
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43379&action=edit
source file

The attached tescase (2 files) gives the following warning:

nathans@devvm2452:104>./xgcc -B./ -nostdinc -isystem .   -c pun.c
pun.c: In function 'init':
pun.c:7:3: warning: dereferencing type-punned pointer will break
strict-aliasing rules [-Wstrict-aliasing]
   INCREF_BAD (&thing); /* Warning. */
   ^~~~~~~~~~

The actual dereference is happening in a system header file, so this should be
protected.  And indeed that's what happens in the expansion of 'INCREF_OK
(&thing)'  The only difference being the BAD one uses a typedef name and the OK
one uses 'struct name'.

In the typedef case we think the cast location is the macro expansion point. 
in the struct name case we think it's the name token's location.

If one adds -save-temps the warning goes away.  We no longer see the macro
expansions.

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