[Bug c++/27070] New: Different partial template specialization result with different optimization options?

2006-04-06 Thread meter dot ten at gmail dot com
gcc version 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)
gcc version 4.0.3 (Ubuntu 4.0.3-1ubuntu3)

Different  partial template specialization result with different  optimization
options?

1. right result without optimization 
$g++ -O0 -g3 -c test.cpp
$g++ -O0 -g3 -c a.cpp
$g++ -O0 -g3 -o test test.o a.o
$./test
DEFAULT
PARTIAL

2. wrong  result with  optimization 
$g++ -O2 -g0 -c test.cpp
$g++ -O2 -g0 -c a.cpp
$g++ -O2 -g0 -o test test.o a.o
$./test
DEFAULT
DEFAULT
Bug???

3.if write three part in one file ,we get the right result
$g++ -O2 -g0 -o test2  test2
$./test2
DEFAULT
PARTIAL

$g++ -O0 -g3 -o test2  test2
$./test2
DEFAULT
PARTIAL






//
//a.h
//

#ifndef A_H
#define A_H

#include
using namespace std;
template
class A
{
public:
void echo() {cout << "ĬÈÏ" << endl;}
}
;
#endif

//
//a.cpp
//
#include "a.h"
template <>
void
A<0>::echo()
{
cout << "ÌØ»¯" << endl;
}

//
//test.cpp
//
#include "a.h"
int main( int argc, char *argv[] )
{
A<1>  DEFAULT;
A<0>  PARTICULAR;
DEFAULT.echo();
PARTICULAR.echo();

return EXIT_SUCCESS;
}

//
//test2.cpp
//

#include
using namespace std;
template
class A
{
public:
void echo() {cout << "ĬÈÏ" << endl;}
}
;
template <>
void
A<0>::echo()
{
cout << "ÌØ»¯" << endl;
}

int main( int argc, char *argv[] )
{
A<1> DEFAULT;
A<0> PARTICULAR;
DEFAULT.echo();
PARTICULAR.echo();

return EXIT_SUCCESS;
}


-- 
   Summary: Different  partial template specialization result with
different  optimization options?
   Product: gcc
   Version: 4.0.3
Status: UNCONFIRMED
          Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: meter dot ten at gmail dot com


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



[Bug c++/27070] Different partial template specialization result with different optimization options?

2006-04-06 Thread meter dot ten at gmail dot com


--- Comment #1 from meter dot ten at gmail dot com  2006-04-07 02:37 ---
this is not a bug.


-- 

meter dot ten at gmail dot com changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||INVALID


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