public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17519] New: Warning for array of packed non-POD in packed struct
@ 2004-09-16 12:10 timb at bluearc dot com
  2004-09-23  1:41 ` [Bug c++/17519] [3.4/4.0 Regression] " pinskia at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: timb at bluearc dot com @ 2004-09-16 12:10 UTC (permalink / raw)
  To: gcc-bugs

Compiling this with -Wall:
-----
struct A {
  A();
} __attribute__((packed));

struct B {
  A a[2];
} __attribute__((packed));
-----

gives:
test.cpp:6: warning: ignoring packed attribute on unpacked non-POD field `A B::a[2]'

A non-array packed non-POD member does not produce this warning. There is also
no warning if the packed attribute is removed from B and added to the array
declaration inside, even though declaring it on a struct is meant to be
equivalent to declaring it on each member.

May be related to bug 13983.

-- 
           Summary: Warning for array of packed non-POD in packed struct
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: timb at bluearc dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i486-linux
  GCC host triplet: i486-linux
GCC target triplet: i486-linux


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


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

* [Bug c++/17519] [3.4/4.0 Regression] Warning for array of packed non-POD in packed struct
  2004-09-16 12:10 [Bug c++/17519] New: Warning for array of packed non-POD in packed struct timb at bluearc dot com
@ 2004-09-23  1:41 ` pinskia at gcc dot gnu dot org
  2004-11-01  0:46 ` mmitchel at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-23  1:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-23 01:41 -------
Nathan could you comment on this bug?

Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nathan at codesourcery dot
                   |                            |com
  BugsThisDependsOn|                            |13983
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2004-09-23 01:41:51
               date|                            |
            Summary|Warning for array of packed |[3.4/4.0 Regression] Warning
                   |non-POD in packed struct    |for array of packed non-POD
                   |                            |in packed struct
   Target Milestone|---                         |3.4.3


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


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

* [Bug c++/17519] [3.4/4.0 Regression] Warning for array of packed non-POD in packed struct
  2004-09-16 12:10 [Bug c++/17519] New: Warning for array of packed non-POD in packed struct timb at bluearc dot com
  2004-09-23  1:41 ` [Bug c++/17519] [3.4/4.0 Regression] " pinskia at gcc dot gnu dot org
@ 2004-11-01  0:46 ` mmitchel at gcc dot gnu dot org
  2005-01-27  0:34 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-11-01  0:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-11-01 00:46 -------
Postponed until GCC 3.4.4.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4.3                       |3.4.4


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


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

* [Bug c++/17519] [3.4/4.0 Regression] Warning for array of packed non-POD in packed struct
  2004-09-16 12:10 [Bug c++/17519] New: Warning for array of packed non-POD in packed struct timb at bluearc dot com
  2004-09-23  1:41 ` [Bug c++/17519] [3.4/4.0 Regression] " pinskia at gcc dot gnu dot org
  2004-11-01  0:46 ` mmitchel at gcc dot gnu dot org
@ 2005-01-27  0:34 ` pinskia at gcc dot gnu dot org
  2005-01-27 17:51 ` timb at bluearc dot com
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-27  0:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-27 00:34 -------
I want to say the warning is correct but should be given more than it is currently which would rate this 
as a progression instead of a regression.

-- 


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


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

* [Bug c++/17519] [3.4/4.0 Regression] Warning for array of packed non-POD in packed struct
  2004-09-16 12:10 [Bug c++/17519] New: Warning for array of packed non-POD in packed struct timb at bluearc dot com
                   ` (2 preceding siblings ...)
  2005-01-27  0:34 ` pinskia at gcc dot gnu dot org
@ 2005-01-27 17:51 ` timb at bluearc dot com
  2005-02-14 15:51 ` nathan at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: timb at bluearc dot com @ 2005-01-27 17:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From timb at bluearc dot com  2005-01-27 17:50 -------
There's certainly a good case for warning about packing that's likely not to
have the desired results - we've been bitten by that before. But that doesn't
really apply to all non-POD; you can define a subset safe-non-POD (broadly
speaking, no virtual functions/bases and (recursively) no unsafe non-static data
members) where everything still has reasonably predictable representations and
you don't need extra space for polymorphism magic.

So if you do go in that direction, please consider separate warnings for those
non-POD types that can nevertheless safely be packed and those that can't.
Classes made non-POD through fairly innoccuous constructions - e.g.
constructors, simple inheritance - are often useful in abstracting hardware
registers, data formats, etc. We'd be swamped in warnings if we got one for
every packed non-POD, but we definitely do want to know if there's something
that's actually going to mess things up.

-- 


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


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

* [Bug c++/17519] [3.4/4.0 Regression] Warning for array of packed non-POD in packed struct
  2004-09-16 12:10 [Bug c++/17519] New: Warning for array of packed non-POD in packed struct timb at bluearc dot com
                   ` (3 preceding siblings ...)
  2005-01-27 17:51 ` timb at bluearc dot com
@ 2005-02-14 15:51 ` nathan at gcc dot gnu dot org
  2005-02-28 23:05 ` [Bug c++/17519] [3.4/4.0/4.1 " timb at bluearc dot com
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: nathan at gcc dot gnu dot org @ 2005-02-14 15:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From nathan at gcc dot gnu dot org  2005-02-14 10:27 -------
The killer with packing in C++ is that it is so easy to silently take the
address of a field (pass by reference). Until we actually reflect unalignedness
in the type system *no* packing is really safe in C++.

That said, I don't see why the warning would be different for a packed non-array
member.

-- 


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


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

* [Bug c++/17519] [3.4/4.0/4.1 Regression] Warning for array of packed non-POD in packed struct
  2004-09-16 12:10 [Bug c++/17519] New: Warning for array of packed non-POD in packed struct timb at bluearc dot com
                   ` (4 preceding siblings ...)
  2005-02-14 15:51 ` nathan at gcc dot gnu dot org
@ 2005-02-28 23:05 ` timb at bluearc dot com
  2005-05-19 17:49 ` mmitchel at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: timb at bluearc dot com @ 2005-02-28 23:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From timb at bluearc dot com  2005-02-28 17:04 -------
That's orthogonal though - and presumably it only applies to a packed object or
member *whose type is not packed by definition*, because you can so easily end
up passing a pointer or reference to something that doesn't know about the post
facto packing. Where we use packing it's always specified on the struct
definition, which ought to be safe in that respect. (Although I can see that
potentially some work may be required to be able to issue appropriate warnings
for the unsafe uses.)

-- 


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


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

* [Bug c++/17519] [3.4/4.0/4.1 Regression] Warning for array of packed non-POD in packed struct
  2004-09-16 12:10 [Bug c++/17519] New: Warning for array of packed non-POD in packed struct timb at bluearc dot com
                   ` (5 preceding siblings ...)
  2005-02-28 23:05 ` [Bug c++/17519] [3.4/4.0/4.1 " timb at bluearc dot com
@ 2005-05-19 17:49 ` mmitchel at gcc dot gnu dot org
  2005-07-22 21:18 ` pinskia at gcc dot gnu dot org
  2005-09-27 16:21 ` mmitchel at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-05-19 17:49 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4.4                       |3.4.5


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


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

* [Bug c++/17519] [3.4/4.0/4.1 Regression] Warning for array of packed non-POD in packed struct
  2004-09-16 12:10 [Bug c++/17519] New: Warning for array of packed non-POD in packed struct timb at bluearc dot com
                   ` (6 preceding siblings ...)
  2005-05-19 17:49 ` mmitchel at gcc dot gnu dot org
@ 2005-07-22 21:18 ` pinskia at gcc dot gnu dot org
  2005-09-27 16:21 ` mmitchel at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-22 21:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-22 21:13 -------
Moving to 4.0.2 pre Mark.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4.5                       |4.0.2


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


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

* [Bug c++/17519] [3.4/4.0/4.1 Regression] Warning for array of packed non-POD in packed struct
  2004-09-16 12:10 [Bug c++/17519] New: Warning for array of packed non-POD in packed struct timb at bluearc dot com
                   ` (7 preceding siblings ...)
  2005-07-22 21:18 ` pinskia at gcc dot gnu dot org
@ 2005-09-27 16:21 ` mmitchel at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-09-27 16:21 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.0.2                       |4.0.3


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


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

end of thread, other threads:[~2005-09-27 16:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-16 12:10 [Bug c++/17519] New: Warning for array of packed non-POD in packed struct timb at bluearc dot com
2004-09-23  1:41 ` [Bug c++/17519] [3.4/4.0 Regression] " pinskia at gcc dot gnu dot org
2004-11-01  0:46 ` mmitchel at gcc dot gnu dot org
2005-01-27  0:34 ` pinskia at gcc dot gnu dot org
2005-01-27 17:51 ` timb at bluearc dot com
2005-02-14 15:51 ` nathan at gcc dot gnu dot org
2005-02-28 23:05 ` [Bug c++/17519] [3.4/4.0/4.1 " timb at bluearc dot com
2005-05-19 17:49 ` mmitchel at gcc dot gnu dot org
2005-07-22 21:18 ` pinskia at gcc dot gnu dot org
2005-09-27 16:21 ` mmitchel 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).