public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/51013] New: complex::{imag,real}() should maintain lvalue-returning extension in C++11
@ 2011-11-07 21:10 jyasskin at gcc dot gnu.org
  2011-11-07 21:11 ` [Bug libstdc++/51013] " paolo.carlini at oracle dot com
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: jyasskin at gcc dot gnu.org @ 2011-11-07 21:10 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51013
           Summary: complex::{imag,real}() should maintain
                    lvalue-returning extension in C++11
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jyasskin@gcc.gnu.org


In C++98, libstdc++ has an extension to return T& from complex<T>::real() and
::imag() (introduced in r75680). Paolo removed this extension for C++11 in
r135878 citing
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#387. However, the
point of DR387 was to increase the amount of access complex<> provides to its
internals, not to remove existing extensions providing such access.

Removing this extension affects code that passes references to the real or
imaginary parts of a complex number to other routines. While such code can
generally be rewritten in a straightforward way, it seems like an unnecessary
hurdle that should be avoided given all the other changes needed for C++11
compatibility.

The DR387-provided reinterpret_cast<> way of getting access to the addresses
would work if we were migrating to C++11 atomically, but that's impossible in a
large codebase. I believe the reinterpret_cast produces undefined behavior in
C++98 because of the aliasing violation, so we can't use it in code that needs
to be correct in both versions of the language.

So I think the extension should be reinstated.


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

end of thread, other threads:[~2015-09-06 18:45 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-07 21:10 [Bug libstdc++/51013] New: complex::{imag,real}() should maintain lvalue-returning extension in C++11 jyasskin at gcc dot gnu.org
2011-11-07 21:11 ` [Bug libstdc++/51013] " paolo.carlini at oracle dot com
2011-11-07 23:48 ` marc.glisse at normalesup dot org
2011-11-08  0:11 ` paolo.carlini at oracle dot com
2011-11-08  0:30 ` paolo.carlini at oracle dot com
2011-11-08  1:11 ` jason at gcc dot gnu.org
2011-11-08  7:47 ` marc.glisse at normalesup dot org
2011-11-08  8:13 ` paolo.carlini at oracle dot com
2011-11-08 15:20 ` jason at gcc dot gnu.org
2011-11-08 15:53 ` marc.glisse at normalesup dot org
2011-11-08 18:36 ` daniel.kruegler at googlemail dot com
2011-11-08 18:49 ` marc.glisse at normalesup dot org
2011-11-09 10:42 ` daniel.kruegler at googlemail dot com
2013-07-11 15:03 ` glisse at gcc dot gnu.org
2015-09-06 18:09 ` ross.martin at ieee dot org
2015-09-06 18:45 ` 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).