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

Add voteWatch issue
    XMLWordPrintableJSON

Details

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

    • 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

              Unassigned Unassigned
              sebor Martin Sebor

              Dates

                Created:
                Updated:

                Slack

                  Issue deployment