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

[HP aCC 3.73] bogus error on static_cast initializing a const object in template code

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • External
    • None
    • HP aCC 3.73

    • Compiler Error

    Description

      The following test case reproduces a compiler bug discussed in this thread:

      $ cat z.cpp && aCC -V z.cpp
      struct S {
          int *x;
          int& operator* () const { return *x; }
      };
      
      template <class T> void foo (T x) {
          volatile void* const p = static_cast<volatile void*>(&*x);
      }
      
      int main () {
          foo (S ());
      }
      aCC: HP ANSI C++ B3910B A.03.73
      Error 746: "z.cpp", line 7 # Cannot use static_cast to convert struct S to volatile void *.
              volatile void* const p = static_cast<volatile void*>(&*x);
                                                                   ^
      Error 556: "z.cpp", line 11 # Unable to generate specialization "void foo<S>(S)" due to errors during generation.
              foo (S ());
              ^^^^^^^^^^
      Error 556: "z.cpp", line 11 # Unable to generate specialization "void foo<S>(S)" due to errors during generation.
              foo (S ());
              ^^^^^^^^^^
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            sebor Martin Sebor
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: