From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8431 invoked by alias); 24 Aug 2003 17:44:01 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 8424 invoked by alias); 24 Aug 2003 17:44:01 -0000 Date: Sun, 24 Aug 2003 17:44:00 -0000 From: "gcc-bugzilla at gcc dot gnu dot org" To: gcc-bugs@gcc.gnu.org Message-ID: <20030824174359.12046.cspiel@freenet.de> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/12046] New: parse error in template function X-Bugzilla-Reason: CC X-SW-Source: 2003-08/txt/msg02796.txt.bz2 List-Id: PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12046 Summary: parse error in template function Product: gcc Version: 3.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: cspiel at freenet dot de CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu Environment: System: Linux hydra 2.4.21-ac4 #1 SMP Mon Jul 14 20:13:09 CEST 2003 i686 unknown Architecture: i686 host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: i686-pc-linux-gnu configured with: ../configure --prefix=/usr --infodir=/usr/share/info How-To-Repeat: # 1 "compiler-bug.cc" # 1 "" # 1 "" # 1 "compiler-bug.cc" template struct Traits {}; struct Traits { static const bool b = true; }; struct Traits { static const bool b = false; }; # 31 "compiler-bug.cc" template struct C {}; struct C { template inline static T f(T x) { return -x; } }; struct C { template inline static T f(T x) { return x; } }; # 54 "compiler-bug.cc" template T special_f(T x) { return C::b>::f(x); } template T any_f(T x) { return C::b>::f(x); } int force_instantiation(int i) { return special_f(i) + any_f(i); } $ g++ -v -Wall -c compiler-bug.cc Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3/specs Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --enable-threads Thread model: posix gcc version 3.3 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3/cc1plus -quiet -v -D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=0 -D_GNU_SOURCE compiler-bug.cc -D__GNUG__=3 -quiet -dumpbase compiler-bug.cc -auxbase compiler-bug -Wall -version -o /tmp/ccU7FMbF.s GNU C++ version 3.3 (i686-pc-linux-gnu) compiled by GNU C version 3.3. GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=32000 #include "..." search starts here: #include <...> search starts here: /usr/include/c++/3.3 /usr/include/c++/3.3/i686-pc-linux-gnu /usr/include/c++/3.3/backward /usr/local/include /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3/include /usr/i686-pc-linux-gnu/include /usr/include End of search list. compiler-bug.cc: In function `T any_f(T)': compiler-bug.cc:66: error: parse error before `>' token ------- Additional Comments From cspiel at freenet dot de 2003-08-24 17:43 ------- Fix: This is a work around, not a fix: Replace compile-time function selection via expression template with run-time selection via ternary operator. (This is no very appealing from the optimization point of view and even less appealing from the error/warning point of view, because of spurious error messages, e.g. "comparison of signed with unsigned" when the templated code would compile cleanly.)