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

[HP aCC 6.16] bogus warning #20200 on safe code with new expression

    XMLWordPrintableJSON

    Details

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

      HP aCC 6.16

    • Severity:
      Compiler Warning

      Description

      When compiled with HP aCC 6.16 with +w +O the program below produces a bogus cadvise warning #20200. There is no potential for a null pointer dereference since operator new throws on error and when (n == 0) holds the loop in bar() is not entered.

      $ cat t.cpp && aCC -V -c +O2 +w t.cpp
      struct A {
          char *s;
          A (unsigned n) {
              if (n) s = new char [n]; 
              else s = 0;
          }
      };
      
      char* bar (unsigned n) {
          A a (n);
          for (unsigned i = 0; i != n; ++i)
              a.s [i] = '\0';
          return a.s;
      }
      aCC: HP C/aC++ B3910B A.06.16 [Nov 26 2007]
      "t.cpp", line 12, procedure bar: warning #20200-D: Potential null pointer
                dereference through a is detected (null definition:t.cpp, line 5)
      

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated: