public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/57350] std::align missing
  2013-05-21  8:48 [Bug libstdc++/57350] New: std::align missing potswa at mac dot com
@ 2013-05-21  8:48 ` potswa at mac dot com
  2013-05-21  9:59 ` redi at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: potswa at mac dot com @ 2013-05-21  8:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from David Krauss <potswa at mac dot com> ---
Oh, here's a link to my version:
http://code.google.com/p/c-plus/source/browse/src/util.h#50


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

* [Bug libstdc++/57350] New: std::align missing
@ 2013-05-21  8:48 potswa at mac dot com
  2013-05-21  8:48 ` [Bug libstdc++/57350] " potswa at mac dot com
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: potswa at mac dot com @ 2013-05-21  8:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 57350
           Summary: std::align missing
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: potswa at mac dot com

C++11 §20.6.5 [ptr.align] remains unimplemented.

Several years ago I published what now appears to be a compliant
implementation, but it was under the MIT license. Does that disqualify that
code, or me, from submitting a patch?

As pure, relatively agnostic pointer arithmetic it doesn't seem to fit into the
other groups of functions specified for <memory>, which are implemented in
various separate files.
>From gcc-bugs-return-422730-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue May 21 08:56:57 2013
Return-Path: <gcc-bugs-return-422730-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 1610 invoked by alias); 21 May 2013 08:56:56 -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 1097 invoked by uid 48); 21 May 2013 08:56:24 -0000
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/53631] [C++11] <regex> is unimplemented
Date: Tue, 21 May 2013 08:56:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: libstdc++
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: redi at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-53631-4-CvyWlOYZai@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-53631-4@http.gcc.gnu.org/bugzilla/>
References: <bug-53631-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: 2013-05/txt/msg01403.txt.bz2
Content-length: 393

http://gcc.gnu.org/bugzilla/show_bug.cgi?idS631

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Yes, we're well aware of all these problems.  What I don't see is anyone
proposing any useful solutions.

If someone sends a patch to remove the <regex> header *without* removing
exported symbols from libstdc++.so I'll happily review it, but I have other
things to work on.


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

* [Bug libstdc++/57350] std::align missing
  2013-05-21  8:48 [Bug libstdc++/57350] New: std::align missing potswa at mac dot com
  2013-05-21  8:48 ` [Bug libstdc++/57350] " potswa at mac dot com
@ 2013-05-21  9:59 ` redi at gcc dot gnu.org
  2014-02-01 17:06 ` vladimir.krivopalov at gmail dot com
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2013-05-21  9:59 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 3119 bytes --]

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to David Krauss from comment #0)
> C++11 §20.6.5 [ptr.align] remains unimplemented.
> 
> Several years ago I published what now appears to be a compliant
> implementation, but it was under the MIT license. Does that disqualify that
> code, or me, from submitting a patch?

Not at all, nothing stops you (as the author) submitting it to the FSF under
the GPL, but to accept it the FSF usually need a copyright asignment on file -
do you have one?
>From gcc-bugs-return-422754-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue May 21 10:16:50 2013
Return-Path: <gcc-bugs-return-422754-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 22734 invoked by alias); 21 May 2013 10:16:49 -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 22401 invoked by uid 48); 21 May 2013 10:16:17 -0000
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/57331] [4.9 Regression] ICE: tree check: expected integer_type or enumeral_type or boolean_type or real_type or fixed_point_type, have pointer_type in int_fits_type_p, at tree.c:8437
Date: Tue, 21 May 2013 10:16:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jakub at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.9.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status assigned_to attachments.created
Message-ID: <bug-57331-4-vuYDDVYuiT@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-57331-4@http.gcc.gnu.org/bugzilla/>
References: <bug-57331-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: 2013-05/txt/msg01427.txt.bz2
Content-length: 570

http://gcc.gnu.org/bugzilla/show_bug.cgi?idW331

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 30150
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id0150&actioníit
gcc49-pr57331.patch

Untested fix.


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

* [Bug libstdc++/57350] std::align missing
  2013-05-21  8:48 [Bug libstdc++/57350] New: std::align missing potswa at mac dot com
  2013-05-21  8:48 ` [Bug libstdc++/57350] " potswa at mac dot com
  2013-05-21  9:59 ` redi at gcc dot gnu.org
@ 2014-02-01 17:06 ` vladimir.krivopalov at gmail dot com
  2014-02-02  3:08 ` potswa at mac dot com
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: vladimir.krivopalov at gmail dot com @ 2014-02-01 17:06 UTC (permalink / raw)
  To: gcc-bugs

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

Vladimir Krivopalov <vladimir.krivopalov at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vladimir.krivopalov at gmail dot c
                   |                            |om

--- Comment #3 from Vladimir Krivopalov <vladimir.krivopalov at gmail dot com> ---
Greetings,

Any chance to get std::align() implementation included in the coming GCC
releases?
What needs to be done for that?


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

* [Bug libstdc++/57350] std::align missing
  2013-05-21  8:48 [Bug libstdc++/57350] New: std::align missing potswa at mac dot com
                   ` (2 preceding siblings ...)
  2014-02-01 17:06 ` vladimir.krivopalov at gmail dot com
@ 2014-02-02  3:08 ` potswa at mac dot com
  2014-02-02  4:14 ` vladimir.krivopalov at gmail dot com
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: potswa at mac dot com @ 2014-02-02  3:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from David Krauss <potswa at mac dot com> ---
Just re-reading now, std::size_t should be std::uintptr_t, but I don't see
anything else that could cause UB. The bitwise "negative" arithmetic should be
OK because it's all on unsigned values.

And if GNU style doesn't allow auto, those should just be uintptr_t or size_t
as appropriate.


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

* [Bug libstdc++/57350] std::align missing
  2013-05-21  8:48 [Bug libstdc++/57350] New: std::align missing potswa at mac dot com
                   ` (3 preceding siblings ...)
  2014-02-02  3:08 ` potswa at mac dot com
@ 2014-02-02  4:14 ` vladimir.krivopalov at gmail dot com
  2014-02-02  4:47 ` potswa at mac dot com
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: vladimir.krivopalov at gmail dot com @ 2014-02-02  4:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Vladimir Krivopalov <vladimir.krivopalov at gmail dot com> ---
(In reply to David Krauss from comment #5)
> Just re-reading now, std::size_t should be std::uintptr_t, but I don't see
> anything else that could cause UB. The bitwise "negative" arithmetic should
> be OK because it's all on unsigned values.
> 
> And if GNU style doesn't allow auto, those should just be uintptr_t or
> size_t as appropriate.

This code looks fine to me at my best knowledge of expected std::align()
behaviour.

I also tried it against the artificial test case described at
https://stackoverflow.com/questions/16305311/usage-issue-of-stdalign and it
doesn't re-align the already aligned pointer.

Not sure if auto keyword is prohibited by GCC internal code style, perhaps
someone from GCC devs could help on that.

Thank you for preparing the fix, David!


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

* [Bug libstdc++/57350] std::align missing
  2013-05-21  8:48 [Bug libstdc++/57350] New: std::align missing potswa at mac dot com
                   ` (4 preceding siblings ...)
  2014-02-02  4:14 ` vladimir.krivopalov at gmail dot com
@ 2014-02-02  4:47 ` potswa at mac dot com
  2014-02-03  7:16 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: potswa at mac dot com @ 2014-02-02  4:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from David Krauss <potswa at mac dot com> ---
Haha, it looks like the MSVC devs forgot to subtract 1. Typical.

I did test my code in a real arena allocator, by the way, so that sort of thing
would not have gotten through.


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

* [Bug libstdc++/57350] std::align missing
  2013-05-21  8:48 [Bug libstdc++/57350] New: std::align missing potswa at mac dot com
                   ` (5 preceding siblings ...)
  2014-02-02  4:47 ` potswa at mac dot com
@ 2014-02-03  7:16 ` redi at gcc dot gnu.org
  2014-02-04  7:03 ` potswa at mac dot com
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2014-02-03  7:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Vladimir Krivopalov from comment #3)
> Any chance to get std::align() implementation included in the coming GCC
> releases?
> What needs to be done for that?

It's too late for GCC 4.9 now.


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

* [Bug libstdc++/57350] std::align missing
  2013-05-21  8:48 [Bug libstdc++/57350] New: std::align missing potswa at mac dot com
                   ` (6 preceding siblings ...)
  2014-02-03  7:16 ` redi at gcc dot gnu.org
@ 2014-02-04  7:03 ` potswa at mac dot com
  2014-02-04  8:29 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: potswa at mac dot com @ 2014-02-04  7:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from David Krauss <potswa at mac dot com> ---
Whoa, there's a nasty bug there, if alignment > space.

inline void *align( std::size_t alignment, std::size_t size,
                    void *&ptr, std::size_t &space ) {
    std::uintptr_t pn = reinterpret_cast< std::uintptr_t >( ptr );
    std::uintptr_t aligned = ( pn + alignment - 1 ) & - alignment;
    size += aligned - pn; // Add padding to size.
    if ( space < size ) return nullptr;
    space -= size;
    return ptr = reinterpret_cast< void * >( aligned );
}

I haven't tested this edit at all.


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

* [Bug libstdc++/57350] std::align missing
  2013-05-21  8:48 [Bug libstdc++/57350] New: std::align missing potswa at mac dot com
                   ` (7 preceding siblings ...)
  2014-02-04  7:03 ` potswa at mac dot com
@ 2014-02-04  8:29 ` redi at gcc dot gnu.org
  2014-02-05  4:21 ` potswa at mac dot com
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2014-02-04  8:29 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-02-04
     Ever confirmed|0                           |1

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Confirmed as unimplemented.


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

* [Bug libstdc++/57350] std::align missing
  2013-05-21  8:48 [Bug libstdc++/57350] New: std::align missing potswa at mac dot com
                   ` (8 preceding siblings ...)
  2014-02-04  8:29 ` redi at gcc dot gnu.org
@ 2014-02-05  4:21 ` potswa at mac dot com
  2014-10-13 14:09 ` redi at gcc dot gnu.org
  2014-10-13 14:11 ` redi at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: potswa at mac dot com @ 2014-02-05  4:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from David Krauss <potswa at mac dot com> ---
No, that code wasn't right either. I'll just leave it at this and a caveat to
the reader:

inline void *align( std::size_t alignment, std::size_t size,
                    void *&ptr, std::size_t &space ) {
    std::uintptr_t pn = reinterpret_cast< std::uintptr_t >( ptr );
    std::uintptr_t aligned = ( pn + alignment - 1 ) & - alignment;
    std::size_t padding = aligned - pn;
    if ( space < size + padding ) return nullptr;
    space -= padding;
    return ptr = reinterpret_cast< void * >( aligned );
}


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

* [Bug libstdc++/57350] std::align missing
  2013-05-21  8:48 [Bug libstdc++/57350] New: std::align missing potswa at mac dot com
                   ` (9 preceding siblings ...)
  2014-02-05  4:21 ` potswa at mac dot com
@ 2014-10-13 14:09 ` redi at gcc dot gnu.org
  2014-10-13 14:11 ` redi at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2014-10-13 14:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Mon Oct 13 14:08:44 2014
New Revision: 216149

URL: https://gcc.gnu.org/viewcvs?rev=216149&root=gcc&view=rev
Log:
    PR libstdc++/57350
    * include/std/memory (align): Do not adjust correctly aligned address.
    * testsuite/20_util/align/2.cc: New.

Added:
    trunk/libstdc++-v3/testsuite/20_util/align/2.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/std/memory


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

* [Bug libstdc++/57350] std::align missing
  2013-05-21  8:48 [Bug libstdc++/57350] New: std::align missing potswa at mac dot com
                   ` (10 preceding siblings ...)
  2014-10-13 14:09 ` redi at gcc dot gnu.org
@ 2014-10-13 14:11 ` redi at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2014-10-13 14:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |5.0

--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed on trunk.


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

end of thread, other threads:[~2014-10-13 14:11 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-21  8:48 [Bug libstdc++/57350] New: std::align missing potswa at mac dot com
2013-05-21  8:48 ` [Bug libstdc++/57350] " potswa at mac dot com
2013-05-21  9:59 ` redi at gcc dot gnu.org
2014-02-01 17:06 ` vladimir.krivopalov at gmail dot com
2014-02-02  3:08 ` potswa at mac dot com
2014-02-02  4:14 ` vladimir.krivopalov at gmail dot com
2014-02-02  4:47 ` potswa at mac dot com
2014-02-03  7:16 ` redi at gcc dot gnu.org
2014-02-04  7:03 ` potswa at mac dot com
2014-02-04  8:29 ` redi at gcc dot gnu.org
2014-02-05  4:21 ` potswa at mac dot com
2014-10-13 14:09 ` redi at gcc dot gnu.org
2014-10-13 14:11 ` redi 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).