public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/61458] New: std::aligned_storage is bigger than expected
@ 2014-06-09 20:30 redi at gcc dot gnu.org
  2014-09-19 13:29 ` [Bug libstdc++/61458] " redi at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2014-06-09 20:30 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 61458
           Summary: std::aligned_storage is bigger than expected
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org

#include <type_traits>

static_assert(sizeof(std::aligned_storage<4>::type) == 4, "");


so.cc: In function ‘int main()’:
so.cc:5:3: error: static assertion failed: 
   static_assert(sizeof(std::aligned_storage<4>::type) == 4, "");
   ^


I think this is conforming, but it would be more useful if it passed.

We use the maximum alignment supported for any type, where we should use the
maximum alignment supported for types less than 4 bytes
>From gcc-bugs-return-453572-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Jun 09 20:34:30 2014
Return-Path: <gcc-bugs-return-453572-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 31481 invoked by alias); 9 Jun 2014 20:34:29 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 31434 invoked by uid 55); 9 Jun 2014 20:34:25 -0000
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/36446] unexplained warning in struct initialization
Date: Mon, 09 Jun 2014 20:34:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c
X-Bugzilla-Version: 4.1.1
X-Bugzilla-Keywords: diagnostic
X-Bugzilla-Severity: normal
X-Bugzilla-Who: mpolacek at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.10.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-36446-4-0WvH80AQZX@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-36446-4@http.gcc.gnu.org/bugzilla/>
References: <bug-36446-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-06/txt/msg00654.txt.bz2
Content-length: 1631

https://gcc.gnu.org/bugzilla/show_bug.cgi?id6446

--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Author: mpolacek
Date: Mon Jun  9 20:33:51 2014
New Revision: 211388

URL: http://gcc.gnu.org/viewcvs?rev!1388&root=gcc&view=rev
Log:
    PR c/36446
    * c-typeck.c (error_init): Call inform instead of error_at.
    (pedwarn_init): Call inform instead of pedwarn.
    (warning_init): Call inform instead of warning_at.

    * gcc.dg/Wcxx-compat-6.c: Change dg-warning to dg-message.
    * gcc.dg/array-2.c: Likewise.
    * gcc.dg/array-const-2.c: Likewise.
    * gcc.dg/ucnid-8.c: Likewise.
    * gcc.dg/vla-init-1.c: Likewise.
    * gcc.dg/array-const-3.c: Change dg-error to dg-message.
    * gcc.dg/c99-flex-array-7.c: Likewise.
    * gcc.dg/init-bad-1.c: Likewise.
    * gcc.dg/init-bad-3.c: Likewise.
    * gcc.dg/init-bad-2.c: Change dg-error and dg-warning to dg-message.
    * gcc.dg/pedwarn-init.c: Add dg-warning.
    * gcc.dg/pr53119.c: Remove dg-excess-errors.

Modified:
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-typeck.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/Wcxx-compat-6.c
    trunk/gcc/testsuite/gcc.dg/array-2.c
    trunk/gcc/testsuite/gcc.dg/array-const-2.c
    trunk/gcc/testsuite/gcc.dg/array-const-3.c
    trunk/gcc/testsuite/gcc.dg/c99-flex-array-7.c
    trunk/gcc/testsuite/gcc.dg/init-bad-1.c
    trunk/gcc/testsuite/gcc.dg/init-bad-2.c
    trunk/gcc/testsuite/gcc.dg/init-bad-3.c
    trunk/gcc/testsuite/gcc.dg/pedwarn-init.c
    trunk/gcc/testsuite/gcc.dg/pr53119.c
    trunk/gcc/testsuite/gcc.dg/ucnid-8.c
    trunk/gcc/testsuite/gcc.dg/vla-init-1.c


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

* [Bug libstdc++/61458] std::aligned_storage is bigger than expected
  2014-06-09 20:30 [Bug libstdc++/61458] New: std::aligned_storage is bigger than expected redi at gcc dot gnu.org
@ 2014-09-19 13:29 ` redi at gcc dot gnu.org
  2015-01-30 10:33 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2014-09-19 13:29 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-09-19
   Target Milestone|---                         |5.0
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
If we're going to fix this we should do it now, before the C++11 ABI is
declared stable.


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

* [Bug libstdc++/61458] std::aligned_storage is bigger than expected
  2014-06-09 20:30 [Bug libstdc++/61458] New: std::aligned_storage is bigger than expected redi at gcc dot gnu.org
  2014-09-19 13:29 ` [Bug libstdc++/61458] " redi at gcc dot gnu.org
@ 2015-01-30 10:33 ` redi at gcc dot gnu.org
  2015-01-30 12:17 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2015-01-30 10:33 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |paolo at gcc dot gnu.org

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The problem is the default value of the _Align parameter, which comes from
alignof(__aligned_storage_msa<_Len>::__type) which is always the maximum
alignment:

  template<size_t _Len>
    struct __aligned_storage_msa
    { 
      union __type
      {
    unsigned char __data[_Len];
    struct __attribute__((__aligned__)) { } __align; 
      };
    };

That effectively ignores _Len and will always have 16-byte alignment, which
means sizeof(aligned_storage<N>) is always at least 16 bytes.

Should the attribute be using __aligned__(_Len) or does that do the wrong thing
in some cases?


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

* [Bug libstdc++/61458] std::aligned_storage is bigger than expected
  2014-06-09 20:30 [Bug libstdc++/61458] New: std::aligned_storage is bigger than expected redi at gcc dot gnu.org
  2014-09-19 13:29 ` [Bug libstdc++/61458] " redi at gcc dot gnu.org
  2015-01-30 10:33 ` redi at gcc dot gnu.org
@ 2015-01-30 12:17 ` redi at gcc dot gnu.org
  2015-01-31 12:12 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2015-01-30 12:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
P.S. this isn't an urgent problem for the library, as we don't use
aligned_storage<N> internally, we always use __aligned_buffer<T> which
specifies the alignment explicitly rather than relying on the 16-byte default.


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

* [Bug libstdc++/61458] std::aligned_storage is bigger than expected
  2014-06-09 20:30 [Bug libstdc++/61458] New: std::aligned_storage is bigger than expected redi at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2015-01-30 12:17 ` redi at gcc dot gnu.org
@ 2015-01-31 12:12 ` paolo.carlini at oracle dot com
  2015-04-22 11:59 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-01-31 12:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Hi Jon. Frankly Are you 100% sure (in terms of middle-end/back-end details)
that the maximum alignment supported for a type of less than 4 bytes is 4? In
that case, your proposal of using  __aligned__((_Len)) certainly makes sense. I
wasn't sure at the time and picked a "safe" choice, probably should have
asked...


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

* [Bug libstdc++/61458] std::aligned_storage is bigger than expected
  2014-06-09 20:30 [Bug libstdc++/61458] New: std::aligned_storage is bigger than expected redi at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2015-01-31 12:12 ` paolo.carlini at oracle dot com
@ 2015-04-22 11:59 ` jakub at gcc dot gnu.org
  2015-05-08 15:06 ` redi at gcc dot gnu.org
  2015-07-16  9:18 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-04-22 11:59 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|5.0                         |5.2

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 5.1 has been released.


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

* [Bug libstdc++/61458] std::aligned_storage is bigger than expected
  2014-06-09 20:30 [Bug libstdc++/61458] New: std::aligned_storage is bigger than expected redi at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2015-04-22 11:59 ` jakub at gcc dot gnu.org
@ 2015-05-08 15:06 ` redi at gcc dot gnu.org
  2015-07-16  9:18 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2015-05-08 15:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Paolo Carlini from comment #4)
> Hi Jon. Frankly Are you 100% sure (in terms of middle-end/back-end details)
> that the maximum alignment supported for a type of less than 4 bytes is 4?

It's a good question, I'm definitely not 100% sure.


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

* [Bug libstdc++/61458] std::aligned_storage is bigger than expected
  2014-06-09 20:30 [Bug libstdc++/61458] New: std::aligned_storage is bigger than expected redi at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2015-05-08 15:06 ` redi at gcc dot gnu.org
@ 2015-07-16  9:18 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-07-16  9:18 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|5.2                         |5.3

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 5.2 is being released, adjusting target milestone to 5.3.


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

end of thread, other threads:[~2015-07-16  9:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-09 20:30 [Bug libstdc++/61458] New: std::aligned_storage is bigger than expected redi at gcc dot gnu.org
2014-09-19 13:29 ` [Bug libstdc++/61458] " redi at gcc dot gnu.org
2015-01-30 10:33 ` redi at gcc dot gnu.org
2015-01-30 12:17 ` redi at gcc dot gnu.org
2015-01-31 12:12 ` paolo.carlini at oracle dot com
2015-04-22 11:59 ` jakub at gcc dot gnu.org
2015-05-08 15:06 ` redi at gcc dot gnu.org
2015-07-16  9:18 ` rguenth at gcc dot gnu.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).