Bug 71772 - temmplates broken.
Summary: temmplates broken.
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-06 01:28 UTC by Jim Michaels
Modified: 2016-08-27 23:21 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
.ii file (156 bytes, text/plain)
2016-07-06 01:28 UTC, Jim Michaels
Details
.s file (39 bytes, text/plain)
2016-07-06 01:29 UTC, Jim Michaels
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jim Michaels 2016-07-06 01:28:08 UTC
Created attachment 38836 [details]
.ii file

template<class I>I func(I n) {
	return n+2;
}

template<class I>
I func2(I n) {
	return n-2;
}

int main(void) {
	int i=<int>func(12);
	int b=<int>func(14);
	return i;
}



Tue 07/05/2016 18:24:48.75|C:\Users\Kristina\Desktop\prj\test|>g++ -v -save-temps -static -o gcc-template-bug.exe gcc-template-bug.cpp
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/gcc-7-win32/bin/../libexec/gcc/i686-w64-mingw32/7.0.0/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: /home/cauchy/vcs/svn/gcc/trunk/configure --prefix=/home/cauchy/native/gcc-7-win32 --with-sysroot=/home/cauchy/native/gcc-7-win32 --build=x
86_64-unknown-linux-gnu --host=i686-w64-mingw32 --target=i686-w64-mingw32 --disable-multilib --disable-nls --disable-win32-registry --disable-gcov-tool --e
nable-checking=release --enable-languages=c,c++,fortran --enable-fully-dynamic-string --with-arch=core2 --with-tune=generic
Thread model: win32
gcc version 7.0.0 20160609 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-static' '-o' 'gcc-template-bug.exe' '-mtune=generic' '-march=core2'
 c:/gcc-7-win32/bin/../libexec/gcc/i686-w64-mingw32/7.0.0/cc1plus.exe -E -quiet -v -iprefix c:\gcc-7-win32\bin\../lib/gcc/i686-w64-mingw32/7.0.0/ -isysroot
 c:\gcc-7-win32\bin\../../gcc-7-win32 -U_REENTRANT gcc-template-bug.cpp -mtune=generic -march=core2 -fpch-preprocess -o gcc-template-bug.ii
ignoring duplicate directory "c:/gcc-7-win32/lib/gcc/../../lib/gcc/i686-w64-mingw32/7.0.0/../../../../include/c++/7.0.0"
ignoring duplicate directory "c:/gcc-7-win32/lib/gcc/../../lib/gcc/i686-w64-mingw32/7.0.0/../../../../include/c++/7.0.0/i686-w64-mingw32"
ignoring duplicate directory "c:/gcc-7-win32/lib/gcc/../../lib/gcc/i686-w64-mingw32/7.0.0/../../../../include/c++/7.0.0/backward"
ignoring duplicate directory "c:/gcc-7-win32/lib/gcc/../../lib/gcc/i686-w64-mingw32/7.0.0/include"
ignoring nonexistent directory "c:\gcc-7-win32\bin\../../gcc-7-win32/home/cauchy/native/gcc-7-win32/lib/gcc/i686-w64-mingw32/7.0.0/../../../../include"
ignoring duplicate directory "c:/gcc-7-win32/lib/gcc/../../lib/gcc/i686-w64-mingw32/7.0.0/include-fixed"
ignoring duplicate directory "c:/gcc-7-win32/lib/gcc/../../lib/gcc/i686-w64-mingw32/7.0.0/../../../../i686-w64-mingw32/include"
ignoring nonexistent directory "c:\gcc-7-win32\bin\../../gcc-7-win32/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
 c:\gcc-7-win32\bin\../lib/gcc/i686-w64-mingw32/7.0.0/../../../../include/c++/7.0.0
 c:\gcc-7-win32\bin\../lib/gcc/i686-w64-mingw32/7.0.0/../../../../include/c++/7.0.0/i686-w64-mingw32
 c:\gcc-7-win32\bin\../lib/gcc/i686-w64-mingw32/7.0.0/../../../../include/c++/7.0.0/backward
 c:\gcc-7-win32\bin\../lib/gcc/i686-w64-mingw32/7.0.0/include
 c:\gcc-7-win32\bin\../lib/gcc/i686-w64-mingw32/7.0.0/include-fixed
 c:\gcc-7-win32\bin\../lib/gcc/i686-w64-mingw32/7.0.0/../../../../i686-w64-mingw32/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-static' '-o' 'gcc-template-bug.exe' '-mtune=generic' '-march=core2'
 c:/gcc-7-win32/bin/../libexec/gcc/i686-w64-mingw32/7.0.0/cc1plus.exe -fpreprocessed gcc-template-bug.ii -quiet -dumpbase gcc-template-bug.cpp -mtune=gener
ic -march=core2 -auxbase gcc-template-bug -version -o gcc-template-bug.s
GNU C++14 (GCC) version 7.0.0 20160609 (experimental) (i686-w64-mingw32)
        compiled by GNU C version 7.0.0 20160609 (experimental), GMP version 6.1.0, MPFR version 3.1.4-p2, MPC version 1.0.3, isl version 0.15
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++14 (GCC) version 7.0.0 20160609 (experimental) (i686-w64-mingw32)
        compiled by GNU C version 7.0.0 20160609 (experimental), GMP version 6.1.0, MPFR version 3.1.4-p2, MPC version 1.0.3, isl version 0.15
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 85f4626b884448f9672ebbd3379aa3ed
gcc-template-bug.cpp: In function 'int main()':
gcc-template-bug.cpp:11:8: error: expected primary-expression before '<' token
  int i=<int>func(12);
        ^
gcc-template-bug.cpp:11:9: error: expected primary-expression before 'int'
  int i=<int>func(12);
         ^~~
gcc-template-bug.cpp:12:8: error: expected primary-expression before '<' token
  int b=<int>func(14);
        ^
gcc-template-bug.cpp:12:9: error: expected primary-expression before 'int'
  int b=<int>func(14);
         ^~~

Tue 07/05/2016 18:24:55.24|C:\Users\Kristina\Desktop\prj\test|>
Comment 1 Jim Michaels 2016-07-06 01:29:28 UTC
Created attachment 38837 [details]
.s file
Comment 2 Marc Glisse 2016-07-06 01:47:15 UTC
That's not how C++ templates are used, and the error message is in the right location.
Comment 3 Jim Michaels 2016-08-27 23:21:08 UTC
this was a problem for a while. it has been fixed as of late. I also learned that it's func2<int>(n);