public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/51654] New: C++ preprocessor bug with -maltivec and typedefs involving 'vector'
@ 2011-12-22 15:15 mathias at gaunard dot com
  2011-12-22 15:28 ` [Bug target/51654] " mathias at gaunard dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: mathias at gaunard dot com @ 2011-12-22 15:15 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51654
           Summary: C++ preprocessor bug with -maltivec and typedefs
                    involving 'vector'
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: mathias@gaunard.com


The following C++ code

template<class T>
struct test
{
    typedef T::vector vector;
};

when preprocessed using the following command
g++ -maltivec -E test.cpp

generates the following output:

template<class T>
struct test
{
    typedef T::vector;
};

Expected output should be the file unchanged.

In particular, this prevents from using significant parts of the Boost C++
libraries with AltiVec enabled.

I'm not sure which is the best place to affect this bug (c++, preprocessor,
target), feel free to move it.
Affecting to target because it seems similar to bug #39558.


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

* [Bug target/51654] C++ preprocessor bug with -maltivec and typedefs involving 'vector'
  2011-12-22 15:15 [Bug target/51654] New: C++ preprocessor bug with -maltivec and typedefs involving 'vector' mathias at gaunard dot com
@ 2011-12-22 15:28 ` mathias at gaunard dot com
  2011-12-22 15:44 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mathias at gaunard dot com @ 2011-12-22 15:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Mathias Gaunard <mathias at gaunard dot com> 2011-12-22 15:16:18 UTC ---
Excuse the typo, the above code should have been

template<class T>
struct test
{
    typedef typename T::vector vector;
};

to be valid C++ code.

The " vector" bit is incorrectly removed in both cases though.


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

* [Bug target/51654] C++ preprocessor bug with -maltivec and typedefs involving 'vector'
  2011-12-22 15:15 [Bug target/51654] New: C++ preprocessor bug with -maltivec and typedefs involving 'vector' mathias at gaunard dot com
  2011-12-22 15:28 ` [Bug target/51654] " mathias at gaunard dot com
@ 2011-12-22 15:44 ` redi at gcc dot gnu.org
  2011-12-22 16:05 ` mathias at gaunard dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2011-12-22 15:44 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2011-12-22
     Ever Confirmed|0                           |1

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-12-22 15:36:34 UTC ---
you haven't said what version you're using

http://gcc.gnu.org/bugs/


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

* [Bug target/51654] C++ preprocessor bug with -maltivec and typedefs involving 'vector'
  2011-12-22 15:15 [Bug target/51654] New: C++ preprocessor bug with -maltivec and typedefs involving 'vector' mathias at gaunard dot com
  2011-12-22 15:28 ` [Bug target/51654] " mathias at gaunard dot com
  2011-12-22 15:44 ` redi at gcc dot gnu.org
@ 2011-12-22 16:05 ` mathias at gaunard dot com
  2011-12-22 18:45 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mathias at gaunard dot com @ 2011-12-22 16:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Mathias Gaunard <mathias at gaunard dot com> 2011-12-22 15:54:20 UTC ---
The workarounds
#undef vector
or
compiling with -Dvector=vector
seem to work.

But shouldn't this not be necessary when altivec.h is not included?


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

* [Bug target/51654] C++ preprocessor bug with -maltivec and typedefs involving 'vector'
  2011-12-22 15:15 [Bug target/51654] New: C++ preprocessor bug with -maltivec and typedefs involving 'vector' mathias at gaunard dot com
                   ` (2 preceding siblings ...)
  2011-12-22 16:05 ` mathias at gaunard dot com
@ 2011-12-22 18:45 ` pinskia at gcc dot gnu.org
  2011-12-22 18:58 ` mathias at gaunard dot com
  2013-06-20 14:36 ` win_wa at gmx dot net
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-12-22 18:45 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |powerpc*-*-*

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-12-22 18:43:37 UTC ---
Can you provide the output of "gcc -v"?


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

* [Bug target/51654] C++ preprocessor bug with -maltivec and typedefs involving 'vector'
  2011-12-22 15:15 [Bug target/51654] New: C++ preprocessor bug with -maltivec and typedefs involving 'vector' mathias at gaunard dot com
                   ` (3 preceding siblings ...)
  2011-12-22 18:45 ` pinskia at gcc dot gnu.org
@ 2011-12-22 18:58 ` mathias at gaunard dot com
  2013-06-20 14:36 ` win_wa at gmx dot net
  5 siblings, 0 replies; 7+ messages in thread
From: mathias at gaunard dot com @ 2011-12-22 18:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Mathias Gaunard <mathias at gaunard dot com> 2011-12-22 18:48:36 UTC ---
gaunard@emeria:~$ g++-4.6 -v
Using built-in specs.
COLLECT_GCC=g++-4.6
COLLECT_LTO_WRAPPER=/usr/lib/gcc/powerpc-linux-gnu/4.6.0/lto-wrapper
Target: powerpc-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.6-20101220-1' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.6 --enable-shared --enable-multiarch
--enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-plugin --enable-gold --enable-ld=default
--with-plugin-ld=ld.gold --enable-objc-gc --enable-secureplt
--disable-softfloat --enable-targets=powerpc-linux,powerpc64-linux
--with-cpu=default32 --disable-werror --with-long-double-128
--enable-checking=release --build=powerpc-linux-gnu --host=powerpc-linux-gnu
--target=powerpc-linux-gnu
Thread model: posix
gcc version 4.6.0 20101220 (experimental) [trunk revision 168097]
(Ubuntu/Linaro 4.6-20101220-1)


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

* [Bug target/51654] C++ preprocessor bug with -maltivec and typedefs involving 'vector'
  2011-12-22 15:15 [Bug target/51654] New: C++ preprocessor bug with -maltivec and typedefs involving 'vector' mathias at gaunard dot com
                   ` (4 preceding siblings ...)
  2011-12-22 18:58 ` mathias at gaunard dot com
@ 2013-06-20 14:36 ` win_wa at gmx dot net
  5 siblings, 0 replies; 7+ messages in thread
From: win_wa at gmx dot net @ 2013-06-20 14:36 UTC (permalink / raw)
  To: gcc-bugs

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

Mathias Winkel <win_wa at gmx dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |win_wa at gmx dot net

--- Comment #6 from Mathias Winkel <win_wa at gmx dot net> ---
Unfortunately, the way the altivec extensions are defined still poses some
issues when using the latest GNU C Preprocessor. The configure flags for my GCC
are given below.
We are using the cpp to preprocess some of our Fortran code that makes heavy
use of variadic parameter macros etc.
In one of our source files, there is a Fortran comment "! Separation vector".
Here, the cpp recognizes 'vector' as a predefined macro (apparently with
missing parameters, compare
http://gcc.gnu.org/onlinedocs/gcc/PowerPC-AltiVec_002fVSX-Built_002din-Functions.html)
and inserts a number of empty lines that prevent to Fortran code from being
compileable. 

A reduced test example is:

XXX@juqueen1:~/gcc-test/pepc $ cat testbla
! separation vector
// separation vector

! separation vector int a
// separation vector int a

XXX@juqueen1:~/gcc-test/pepc $ cpp -P -C testbla 
! separation
 vector
// separation vector
! separation vector int a
// separation vector int a

Interestingly, nothing happens for 'vector int a', i.e. with trailing arguments
or in C++ comments.
One solution is to explicitly undefine 'vector':

XXX@juqueen1:~/gcc-test/pepc $ cpp -P -C -Uvector testbla 
! separation vector
// separation vector
! separation vector int a
// separation vector int a

However, it would be more desireable of the code was just left unchanged of the
'vector ...' pattern is not matched or if it is found behind the exclamation
mark that introduces Fortran comments.



======
GCC configure options:

XXX@juqueen1:~/gcc-test $ cpp -v       
Using built-in specs.
COLLECT_GCC=cpp
Target: powerpc64-bgq-linux
Configured with: ../gcc_source/configure --disable-bootstrap
--prefix=/bgsys/local/gcc/4.9 --program-suffix= --program-prefix= --enable-lto
--disable-checking --enable-shared --enable-threads=posix
--target=powerpc64-bgq-linux --host=powerpc64-linux-gnu
--build=powerpc64-linux-gnu --enable-secureplt --disable-libmudflap
--disable-libspp --enable-languages=c,c++,fortran,lto --disable-multilib
--with-long-double-128
--with-headers=/bgsys/drivers/ppcfloor//gnu-linux/powerpc64-bgq-linux//sys-include
--with-libs=/bgsys/drivers/ppcfloor//gnu-linux/powerpc64-bgq-linux//lib
--with-bin=/bgsys/drivers/ppcfloor//gnu-linux/powerpc64-bgq-linux//bin
--with-sbin=/bgsys/drivers/ppcfloor//gnu-linux/powerpc64-bgq-linux//sbin :
(reconfigured) ../gcc_source/configure --disable-bootstrap
--prefix=/bgsys/local/gcc/4.9 --program-suffix= --program-prefix= --enable-lto
--disable-checking --enable-shared --enable-threads=posix
--target=powerpc64-bgq-linux --host=powerpc64-linux-gnu
--build=powerpc64-linux-gnu --enable-secureplt --disable-libmudflap
--disable-libspp --enable-languages=c,c++,fortran,lto --disable-multilib
--with-long-double-128
--with-headers=/bgsys/drivers/ppcfloor//gnu-linux/powerpc64-bgq-linux//sys-include
--with-libs=/bgsys/drivers/ppcfloor//gnu-linux/powerpc64-bgq-linux//lib
--with-bin=/bgsys/drivers/ppcfloor//gnu-linux/powerpc64-bgq-linux//bin
--with-sbin=/bgsys/drivers/ppcfloor//gnu-linux/powerpc64-bgq-linux//sbin
Thread model: posix
gcc version 4.9.0 20130620 (experimental) (GCC)


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

end of thread, other threads:[~2013-06-20 14:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-22 15:15 [Bug target/51654] New: C++ preprocessor bug with -maltivec and typedefs involving 'vector' mathias at gaunard dot com
2011-12-22 15:28 ` [Bug target/51654] " mathias at gaunard dot com
2011-12-22 15:44 ` redi at gcc dot gnu.org
2011-12-22 16:05 ` mathias at gaunard dot com
2011-12-22 18:45 ` pinskia at gcc dot gnu.org
2011-12-22 18:58 ` mathias at gaunard dot com
2013-06-20 14:36 ` win_wa at gmx dot net

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).