public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/17426] New: Emit mandatory warning for manual expansions of offsetof
@ 2004-09-12  1:37 giovannibajo at libero dot it
  2004-09-12  1:38 ` [Bug c/17426] " giovannibajo at libero dot it
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: giovannibajo at libero dot it @ 2004-09-12  1:37 UTC (permalink / raw)
  To: gcc-bugs

RTH's patch for PR 17396 reintroduced support for the old-skool manual 
expansion of offsetof within constant expression - a thing which is forbidden 
by C90 rules and that we will stop accepting one day.

Meanwhile, it makes sense to warn people about this change, since it is a 
widespread idiom. I propose a mandatory warning to be emitted in this case:

warning: this custom definition of offsetof is not a valid constant expression 
in ISO C
info: use the offsetof macro from <stddef.h> to disable this warning

JSM, I would appreciate your comments on this PR (especially, the wording of 
the message, pedwarn vs warn, mandatory or not), before I write up the patch.

-- 
           Summary: Emit mandatory warning for manual expansions of offsetof
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: giovannibajo at libero dot it
        ReportedBy: giovannibajo at libero dot it
                CC: gcc-bugs at gcc dot gnu dot org,jsm28 at gcc dot gnu dot
                    org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17426


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/17426] Emit mandatory warning for manual expansions of offsetof
  2004-09-12  1:37 [Bug c/17426] New: Emit mandatory warning for manual expansions of offsetof giovannibajo at libero dot it
@ 2004-09-12  1:38 ` giovannibajo at libero dot it
  2004-09-12  1:39 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: giovannibajo at libero dot it @ 2004-09-12  1:38 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17426


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/17426] Emit mandatory warning for manual expansions of offsetof
  2004-09-12  1:37 [Bug c/17426] New: Emit mandatory warning for manual expansions of offsetof giovannibajo at libero dot it
  2004-09-12  1:38 ` [Bug c/17426] " giovannibajo at libero dot it
@ 2004-09-12  1:39 ` pinskia at gcc dot gnu dot org
  2004-09-12 11:11 ` jsm at polyomino dot org dot uk
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-12  1:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-12 01:39 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2004-09-12 01:39:19
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17426


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/17426] Emit mandatory warning for manual expansions of offsetof
  2004-09-12  1:37 [Bug c/17426] New: Emit mandatory warning for manual expansions of offsetof giovannibajo at libero dot it
  2004-09-12  1:38 ` [Bug c/17426] " giovannibajo at libero dot it
  2004-09-12  1:39 ` pinskia at gcc dot gnu dot org
@ 2004-09-12 11:11 ` jsm at polyomino dot org dot uk
  2004-09-12 13:29 ` giovannibajo at libero dot it
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jsm at polyomino dot org dot uk @ 2004-09-12 11:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jsm at polyomino dot org dot uk  2004-09-12 11:11 -------
Subject: Re:  New: Emit mandatory warning for manual expansions
 of offsetof

On Sun, 12 Sep 2004, giovannibajo at libero dot it wrote:

> Meanwhile, it makes sense to warn people about this change, since it is a 
> widespread idiom. I propose a mandatory warning to be emitted in this case:
> 
> warning: this custom definition of offsetof is not a valid constant expression 
> in ISO C
> info: use the offsetof macro from <stddef.h> to disable this warning
> 
> JSM, I would appreciate your comments on this PR (especially, the wording of 
> the message, pedwarn vs warn, mandatory or not), before I write up the patch.

In what cases do you propose to diagnose this?  After all, it's perfectly 
valid if a constant isn't required (using the implementation-defined 
conversions between integers and pointers), and fits the long-established 
GCC extension of symbolic difference constant expressions if being used in 
a static initializer; it's only where an integer constant expression is 
required, as in bug 17396 (static array dimension) or for case labels, 
enum values, bit-field widths, null pointer constants, designators for 
array initializers, that there's a problem.  I would guess that array 
dimensions and maybe designators are the cases fake-offsetof is most 
likely to be being used in.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17426


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/17426] Emit mandatory warning for manual expansions of offsetof
  2004-09-12  1:37 [Bug c/17426] New: Emit mandatory warning for manual expansions of offsetof giovannibajo at libero dot it
                   ` (2 preceding siblings ...)
  2004-09-12 11:11 ` jsm at polyomino dot org dot uk
@ 2004-09-12 13:29 ` giovannibajo at libero dot it
  2004-09-12 14:30 ` jsm at polyomino dot org dot uk
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: giovannibajo at libero dot it @ 2004-09-12 13:29 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-09-12 13:29 -------
(In reply to comment #2)

> it's only where an integer constant expression is 
> required, as in bug 17396 (static array dimension) or for case labels, 
> enum values, bit-field widths, null pointer constants, designators for 
> array initializers, that there's a problem.

Thanks for the list. I will try to activate the warning in these contexts, but 
I do not know the C frontend, so maybe I'll need to do this incrementally.

> fits the long-established 
> GCC extension of symbolic difference constant expressions if being used in 
> a static initializer

This could be a pedwarn, then, right?

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17426


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/17426] Emit mandatory warning for manual expansions of offsetof
  2004-09-12  1:37 [Bug c/17426] New: Emit mandatory warning for manual expansions of offsetof giovannibajo at libero dot it
                   ` (3 preceding siblings ...)
  2004-09-12 13:29 ` giovannibajo at libero dot it
@ 2004-09-12 14:30 ` jsm at polyomino dot org dot uk
  2005-03-13  5:38 ` pinskia at gcc dot gnu dot org
  2005-03-13  5:39 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: jsm at polyomino dot org dot uk @ 2004-09-12 14:30 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jsm at polyomino dot org dot uk  2004-09-12 14:30 -------
Subject: Re:  Emit mandatory warning for manual expansions of
 offsetof

On Sun, 12 Sep 2004, giovannibajo at libero dot it wrote:

> > fits the long-established 
> > GCC extension of symbolic difference constant expressions if being used in 
> > a static initializer
> 
> This could be a pedwarn, then, right?

A pedwarn for uses where integer constant expressions are required.  The 
intention as described in my proposed formal models is that symbolic 
difference constant expressions are an implementation-defined other kind 
of constant expression acceptable in initializers, i.e. not diagnosed 
there.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17426


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/17426] Emit mandatory warning for manual expansions of offsetof
  2004-09-12  1:37 [Bug c/17426] New: Emit mandatory warning for manual expansions of offsetof giovannibajo at libero dot it
                   ` (4 preceding siblings ...)
  2004-09-12 14:30 ` jsm at polyomino dot org dot uk
@ 2005-03-13  5:38 ` pinskia at gcc dot gnu dot org
  2005-03-13  5:39 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-13  5:38 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
   Last reconfirmed|2004-12-12 01:43:40         |2005-03-13 05:37:56
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17426


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/17426] Emit mandatory warning for manual expansions of offsetof
  2004-09-12  1:37 [Bug c/17426] New: Emit mandatory warning for manual expansions of offsetof giovannibajo at libero dot it
                   ` (5 preceding siblings ...)
  2005-03-13  5:38 ` pinskia at gcc dot gnu dot org
@ 2005-03-13  5:39 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-13  5:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-03-13 05:38 -------
A note here, glibc and a couple of other projects would have been helped by this warning as they have 
code which uses the manual expansion of offsetof.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17426


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-03-13  5:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-12  1:37 [Bug c/17426] New: Emit mandatory warning for manual expansions of offsetof giovannibajo at libero dot it
2004-09-12  1:38 ` [Bug c/17426] " giovannibajo at libero dot it
2004-09-12  1:39 ` pinskia at gcc dot gnu dot org
2004-09-12 11:11 ` jsm at polyomino dot org dot uk
2004-09-12 13:29 ` giovannibajo at libero dot it
2004-09-12 14:30 ` jsm at polyomino dot org dot uk
2005-03-13  5:38 ` pinskia at gcc dot gnu dot org
2005-03-13  5:39 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).