public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/28271] New: Specialization of a function is not called if compile with -03 option
@ 2006-07-05 13:08 maxime dot fiandino at imag dot fr
2006-07-05 13:11 ` [Bug c++/28271] " maxime dot fiandino at imag dot fr
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: maxime dot fiandino at imag dot fr @ 2006-07-05 13:08 UTC (permalink / raw)
To: gcc-bugs
The specialization of a function is not called if compile with -03 option,
the generic implementation is called insteed.
This appear only if the declaration of the specialization is in another
file.
The specialization is called if compiled with -02 or lees optimization, or
if the generic implementation is declared with the buildin noinline.
Configuration of gcc -v:
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../src/configure
--prefix=/project/spg/tools/Open-Sources/gcc/4.1.1/Linux-x86/
--enable-__cxa_atexit --enable-shared --enable-long-long --enable-threads
--enable-languages=c,c++ --with-gnu-as --with-gnu-ar --with-gnu-ld --with-gcc
Thread model: posix
gcc version 4.1.1
Three files:
header
#ifndef _TCLASS_H_
#define _TCLASS_H_
template<typename T> bool foo(T val)
{
return false;
}
#endif
scpecialization:
#include "tclass.h"
template<> bool foo(int val)
{
return true;
}
main:
#include "tclass.h"
int main() {
return(foo(1));
}
--
Summary: Specialization of a function is not called if compile
with -03 option
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: maxime dot fiandino at imag dot fr
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28271
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/28271] Specialization of a function is not called if compile with -03 option
2006-07-05 13:08 [Bug c++/28271] New: Specialization of a function is not called if compile with -03 option maxime dot fiandino at imag dot fr
@ 2006-07-05 13:11 ` maxime dot fiandino at imag dot fr
2006-07-05 13:12 ` maxime dot fiandino at imag dot fr
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: maxime dot fiandino at imag dot fr @ 2006-07-05 13:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from maxime dot fiandino at imag dot fr 2006-07-05 13:11 -------
Created an attachment (id=11829)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11829&action=view)
The main, just call the template function foo and return the return value
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28271
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/28271] Specialization of a function is not called if compile with -03 option
2006-07-05 13:08 [Bug c++/28271] New: Specialization of a function is not called if compile with -03 option maxime dot fiandino at imag dot fr
2006-07-05 13:11 ` [Bug c++/28271] " maxime dot fiandino at imag dot fr
@ 2006-07-05 13:12 ` maxime dot fiandino at imag dot fr
2006-07-05 13:13 ` maxime dot fiandino at imag dot fr
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: maxime dot fiandino at imag dot fr @ 2006-07-05 13:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from maxime dot fiandino at imag dot fr 2006-07-05 13:12 -------
Created an attachment (id=11830)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11830&action=view)
the specialization
The specialization on int return true
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28271
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/28271] Specialization of a function is not called if compile with -03 option
2006-07-05 13:08 [Bug c++/28271] New: Specialization of a function is not called if compile with -03 option maxime dot fiandino at imag dot fr
2006-07-05 13:11 ` [Bug c++/28271] " maxime dot fiandino at imag dot fr
2006-07-05 13:12 ` maxime dot fiandino at imag dot fr
@ 2006-07-05 13:13 ` maxime dot fiandino at imag dot fr
2006-07-05 13:14 ` maxime dot fiandino at imag dot fr
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: maxime dot fiandino at imag dot fr @ 2006-07-05 13:13 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from maxime dot fiandino at imag dot fr 2006-07-05 13:12 -------
Created an attachment (id=11831)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11831&action=view)
The header with the generic implementation
The generic template function return false
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28271
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/28271] Specialization of a function is not called if compile with -03 option
2006-07-05 13:08 [Bug c++/28271] New: Specialization of a function is not called if compile with -03 option maxime dot fiandino at imag dot fr
` (2 preceding siblings ...)
2006-07-05 13:13 ` maxime dot fiandino at imag dot fr
@ 2006-07-05 13:14 ` maxime dot fiandino at imag dot fr
2006-07-05 13:18 ` maxime dot fiandino at imag dot fr
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: maxime dot fiandino at imag dot fr @ 2006-07-05 13:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from maxime dot fiandino at imag dot fr 2006-07-05 13:14 -------
Created an attachment (id=11832)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11832&action=view)
The makefile to test
This makefile create two executable
TC1 compiled with -02 which work well
TC2 compiled with -O3 which don't
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28271
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/28271] Specialization of a function is not called if compile with -03 option
2006-07-05 13:08 [Bug c++/28271] New: Specialization of a function is not called if compile with -03 option maxime dot fiandino at imag dot fr
` (3 preceding siblings ...)
2006-07-05 13:14 ` maxime dot fiandino at imag dot fr
@ 2006-07-05 13:18 ` maxime dot fiandino at imag dot fr
2006-07-05 14:04 ` rguenth at gcc dot gnu dot org
2006-07-05 14:33 ` maxime dot fiandino at imag dot fr
6 siblings, 0 replies; 8+ messages in thread
From: maxime dot fiandino at imag dot fr @ 2006-07-05 13:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from maxime dot fiandino at imag dot fr 2006-07-05 13:18 -------
This bug was firstly discover under gcc3.2.3, then we test with 4.1.1 with the
same results. The test case is very short.
--
maxime dot fiandino at imag dot fr changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |maxime dot fiandino at imag
| |dot fr
Known to fail| |3.2.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28271
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/28271] Specialization of a function is not called if compile with -03 option
2006-07-05 13:08 [Bug c++/28271] New: Specialization of a function is not called if compile with -03 option maxime dot fiandino at imag dot fr
` (4 preceding siblings ...)
2006-07-05 13:18 ` maxime dot fiandino at imag dot fr
@ 2006-07-05 14:04 ` rguenth at gcc dot gnu dot org
2006-07-05 14:33 ` maxime dot fiandino at imag dot fr
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-07-05 14:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from rguenth at gcc dot gnu dot org 2006-07-05 14:04 -------
You need to make the specialization visible at the point of instantiation.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28271
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/28271] Specialization of a function is not called if compile with -03 option
2006-07-05 13:08 [Bug c++/28271] New: Specialization of a function is not called if compile with -03 option maxime dot fiandino at imag dot fr
` (5 preceding siblings ...)
2006-07-05 14:04 ` rguenth at gcc dot gnu dot org
@ 2006-07-05 14:33 ` maxime dot fiandino at imag dot fr
6 siblings, 0 replies; 8+ messages in thread
From: maxime dot fiandino at imag dot fr @ 2006-07-05 14:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from maxime dot fiandino at imag dot fr 2006-07-05 14:33 -------
Thanks, for you quick answer Richard.
Where i don't understand is, it is working well if i declare
the generic template function with:
template<typename T> bool foo(T val) __attribute__(noinline)
{
return false;
}
Just in the case this workaround (perhaps evil) may interest some people.
I return to read the C++ spec this night, i missed this point.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28271
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2006-07-05 14:33 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-05 13:08 [Bug c++/28271] New: Specialization of a function is not called if compile with -03 option maxime dot fiandino at imag dot fr
2006-07-05 13:11 ` [Bug c++/28271] " maxime dot fiandino at imag dot fr
2006-07-05 13:12 ` maxime dot fiandino at imag dot fr
2006-07-05 13:13 ` maxime dot fiandino at imag dot fr
2006-07-05 13:14 ` maxime dot fiandino at imag dot fr
2006-07-05 13:18 ` maxime dot fiandino at imag dot fr
2006-07-05 14:04 ` rguenth at gcc dot gnu dot org
2006-07-05 14:33 ` maxime dot fiandino at imag dot fr
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).