This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/44996] New: decltype produces rvalue reference type for parenthesized id-expression


The expression '(y)' below that constitutes the operand to decltype is neither
an unparenthesized id-expression, a class member access, a function call nor an
invocation of an overloaded operator.

Based on the wording in FCD 14882 (WG21 N3092), this parenthesized
id-expression has type int and is an lvalue.  The type of decltype((y))
is then 'int &'.

The following test case demonstrates that GCC is finding the type to be
'int &&'.  The test case is meant to compile clean.


### Self-contained source (dataa.cpp):
extern int &&y;
typedef int &myIntRef;
typedef decltype((y)) myIntRef;


### Command to reproduce:
g++ -std=c++0x -c dataa.cpp


### Compiler output:
dataa.cpp:3:23: error: conflicting declaration 'typedef int&& myIntRef'
dataa.cpp:2:14: error: 'myIntRef' has a previous declaration as 'typedef int&
myIntRef'


### g++ -v output:
Using built-in specs.
Target: powerpc64-unknown-linux-gnu
Configured with: ../gcc-4.5.0/configure --prefix=/data/gcc
--program-suffix=-4.5.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
Thread model: posix
gcc version 4.5.0 (GCC)


-- 
           Summary: decltype produces rvalue reference type for
                    parenthesized id-expression
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hstong at ca dot ibm dot com
  GCC host triplet: powerpc64-unknown-linux-gnu
GCC target triplet: powerpc64-unknown-linux-gnu


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]