Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8160742

Node::operator new invokes undefined behavior

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 9
    • hotspot
    • b131
    • generic
    • generic

      Node::operator new looks like:

      inline void* operator new(size_t x) throw() {
         Compile* C = Compile::current();
         Node* n = (Node*)C->node_arena()->Amalloc_D(x);
      #ifdef ASSERT
         n->_in = (Node**)n; // magic cookie for assertion check
      #endif
         return (void*)n;
       }

      That assignment of n->_in is, in this context, undefined behavior. Applying member access (either data or function) to storage before the constructor has been applied to it (or after the destructor) is undefined behavior.

            dlong Dean Long
            kbarrett Kim Barrett
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: