[Bug c++/18182] New: Incorrect processing of __attribute__ by the C++ parser

uweigand at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Wed Oct 27 16:19:00 GMT 2004


The C++ parser appears to ignore attributes that apply to nested declarators.

E.g. when trying to define an 'SImode-pointer to int' by 
  typedef int * __attribute__ ((mode (SI))) t;
on s390x-ibm-linux, the C++ parser silently ignores the attribute.

The following test case:

#include <stdio.h>
typedef int * __attribute__ ((mode (SI))) t;

int main (void)
{
  t x;
  printf ("%d %d\n", sizeof (x), sizeof (*x));
}

gives the correct result ("4 4") when compiled with gcc,
but the incorrect result "8 4" when compiled with g++.

[ For a simpler test case on systems without non-Pmode pointers,
try using an invalid mode like:
typedef int * __attribute__ ((mode (TI))) t;
With gcc, this gives an error; g++ accepts the code. ]

See the discussion at 
http://gcc.gnu.org/ml/gcc/2004-10/msg01081.html
for further details.

-- 
           Summary: Incorrect processing of __attribute__ by the C++ parser
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: uweigand at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


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



More information about the Gcc-bugs mailing list