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++/14032] New: non type boolean template argument partial specialization to argument in parent never matches


Compiled with gcc 3.3.1 (cygwin), 3.2.3 (gentoo-linux), mingw32 3.2 the test 
code included in this report generates an endless recursion.
It compiles without errors or warnings so the underlying problem can be quite 
hard to track for the user.

$ cat <<EOF >test.cpp
#include <iostream>

template <bool compare>
struct outer
{
  template <bool compare_with,bool second>
  struct inner           // unspecialized compare != compare_with
  {
    static inline void test()
    {
      std::cout << "invert" << std::endl;
      // call version with inverted template value
      inner<! compare_with, ! second>::test();
    }
  };
  template <bool second> // specialization compare == compare_with
  struct inner<compare,second>
  {
    static inline void test()
    {
      std::cout << "second: " << second << std::endl;
    }
  };
};
int main(int argc,char* argv[],char** envp)
{
  // expected output:
  //  invert
  //  second: true
  outer<false>::inner<true,false>::test();

  // expected output:
  //  second: false
  outer<true>::inner<true,false>::test();

  return 0;
}

EOF
$ make test && ./test

-- 
           Summary: non type boolean template argument partial
                    specialization to argument in parent never matches
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tschwinger at neoscientists dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


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