public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53931] New: [C++11] braced function style cast to reference should be prvalue
@ 2012-07-11 23:14 hstong at ca dot ibm.com
  2021-07-27 21:55 ` [Bug c++/53931] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: hstong at ca dot ibm.com @ 2012-07-11 23:14 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53931
           Summary: [C++11] braced function style cast to reference should
                    be prvalue
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: hstong@ca.ibm.com
              Host: powerpc64-unknown-linux-gnu
            Target: powerpc64-unknown-linux-gnu


C++2011 5.2.3 [expr.type.conv] paragraph 3:

Similarly, a simple-type-specifier or typename-specifier followed by
a braced-init-list creates a temporary object of the specified type
direct-list-initialized (8.5.4) with the specified braced-init-list,
and its value is that temporary object as a prvalue.

In the case below, a braced function-style cast to an rvalue reference type
does not behave the same as a prvalue literal with GCC.

### Self-contained source (refBraceCast.cc):> cat refBraceCast.cc
typedef int &&ir;
void bar(int x) { const_cast<int &&>(ir{x}); }
//void zip(int x) { const_cast<int &&>(0); }  // fails as expected


### Compiler invocation:
g++-4.7.0 -c -std=c++11 refBraceCast.cc; echo rc=$?


### Compiler output:
rc=0


### g++ -v output:> g++-4.7.0 -v
Using built-in specs.
COLLECT_GCC=g++-4.7.0
COLLECT_LTO_WRAPPER=/data/gcc/libexec/gcc/powerpc64-unknown-linux-gnu/4.7.0/lto-wrapper
Target: powerpc64-unknown-linux-gnu
Configured with: ../gcc-4.7.0/configure --prefix=/data/gcc
--program-suffix=-4.7.0 --disable-libssp --disable-libgcj
--enable-version-specific-runtime-libs --with-cpu=default32 --enable-secureplt
--with-long-double-128 --enable-shared --enable-__cxa_atexit
--enable-threads=posix --enable-languages=c,c++,fortran --with-mpfr=/usr/local/
--with-mpc=/usr/local/ --with-gmp=/usr/local/
Thread model: posix
gcc version 4.7.0 (GCC)


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

* [Bug c++/53931] [C++11] braced function style cast to reference should be prvalue
  2012-07-11 23:14 [Bug c++/53931] New: [C++11] braced function style cast to reference should be prvalue hstong at ca dot ibm.com
@ 2021-07-27 21:55 ` pinskia at gcc dot gnu.org
  2023-05-06 16:31 ` pinskia at gcc dot gnu.org
  2023-05-06 16:33 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-27 21:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
typedef int &&ir;
void zip1(int x) { ir{x}; }  

Also is accepted.

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

* [Bug c++/53931] [C++11] braced function style cast to reference should be prvalue
  2012-07-11 23:14 [Bug c++/53931] New: [C++11] braced function style cast to reference should be prvalue hstong at ca dot ibm.com
  2021-07-27 21:55 ` [Bug c++/53931] " pinskia at gcc dot gnu.org
@ 2023-05-06 16:31 ` pinskia at gcc dot gnu.org
  2023-05-06 16:33 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-06 16:31 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jonathan.poelen at gmail dot com

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 109757 has been marked as a duplicate of this bug. ***

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

* [Bug c++/53931] [C++11] braced function style cast to reference should be prvalue
  2012-07-11 23:14 [Bug c++/53931] New: [C++11] braced function style cast to reference should be prvalue hstong at ca dot ibm.com
  2021-07-27 21:55 ` [Bug c++/53931] " pinskia at gcc dot gnu.org
  2023-05-06 16:31 ` pinskia at gcc dot gnu.org
@ 2023-05-06 16:33 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-06 16:33 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|powerpc64-unknown-linux-gnu |
               Host|powerpc64-unknown-linux-gnu |

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1521

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

end of thread, other threads:[~2023-05-06 16:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-11 23:14 [Bug c++/53931] New: [C++11] braced function style cast to reference should be prvalue hstong at ca dot ibm.com
2021-07-27 21:55 ` [Bug c++/53931] " pinskia at gcc dot gnu.org
2023-05-06 16:31 ` pinskia at gcc dot gnu.org
2023-05-06 16:33 ` pinskia 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).