Uploaded image for project: 'C++ Standard Library'
  1. C++ Standard Library
  2. STDCXX-975

[MSVC 8/9] template parsing fails when using less than comparison in metaprogramming conditional

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: External
    • Labels:
      None
    • Environment:

      MSVC 8.0, 9.0

    • Severity:
      Compiler Error

      Description

      The following code fails to compile under both MSVC 8.0 and 9.0.

      template <bool Select, class TypeT, class TypeU>
      struct conditional
      {
          typedef TypeT type;
      };
      
      template <class TypeT, class TypeU>
      struct conditional<false, TypeT, TypeU>
      {
          typedef TypeU type;
      };
      
      template <class TypeT>
      struct size_of
      {
          enum { value = sizeof (TypeT) };
      };
      
      template <class Type1, class Type2, class Type3, class Type4>
      struct largest
      {
          typedef typename
          conditional<(size_of<Type1>::value < size_of<Type2>::value),
                           Type2, Type1>::type Type12;
      
          typedef typename
          conditional<(size_of<Type3>::value < size_of<Type4>::value),
                           Type3, Type4>::type Type34;
      };
      

      An issue has been filed with the vendor here.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              vitek Travis Vitek
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: