This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11540] New: Redefinition of default arguments allowed for template functions


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: Redefinition of default arguments allowed for template
                    functions
           Product: gcc
           Version: 3.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: philippe dot haution at mines-paris dot org
                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

The following code is deemed legal by gcc, although it breaks the one definition
per translation unit rule :

testcase.cc :
-----------------------
namespace ns
{
  template<typename Tv>
  int convert_from_v(Tv v, int prec = -1)
  { return 1; }

}

namespace ns
{
  template<typename Tv>
  int convert_from_v(Tv v, int prec = -2);

}

int main()
{
  return ns::convert_from_v<int>(1);
}

$ g++ testcase.cc -o testcase
$ testcase
$ echo $?
255


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]