Back to success stories

Sample of Defect

Project Name CID Checker Category Developer Description
jirkadanek/Strongtalk 108554 ASSERT_SIDE_EFFECT Incorrect expression This does not have any impact, because it is just an assert. It is kind of funny, though. And this error has been in the codebase for the last 9 years.
File: /home/travis/build/jirkadanek/Strongtalk/vm/interpreter/interpretedIC.cpp
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
    jumpTableEntry* e = jump_table_entry();
    nmethod* nm = e->method();
    assert(nm != NULL, "must have an nmethod");
    return nm->key.selector();
  }
}


jumpTableEntry* InterpretedIC::jump_table_entry() const {
  assert(send_type() == Bytecodes::compiled_send ||
    send_type() == Bytecodes::megamorphic_send, "must be a compiled call");
  assert(first_word()->is_smi(), "must be smi");
  return (jumpTableEntry*) first_word();
}


int InterpretedIC::nof_arguments() const {
  u_char* p = send_code_addr();
  switch (Bytecodes::argument_spec(Bytecodes::Code(*p))) {
    case Bytecodes::recv_0_args: return 0;
    case Bytecodes::recv_1_args: return 1;
    case Bytecodes::recv_2_args: return 2;
    case Bytecodes::recv_n_args: {
      int n = selector()->number_of_arguments();
 <<< CID 108554: Incorrect expression ASSERT_SIDE_EFFECT
 <<< Assignment "n = (int)p[1]" has a side effect.  This code will work differently in a non-debug build.
 < Did you intend to use a comparison ("==") instead?
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
      assert(n = int(*(p+1)), "just checkin'..."); // send_code_addr()+1 must hold the number of arguments
      return n;
                                 }
    case Bytecodes::args_only: return selector()->number_of_arguments();
  }
  ShouldNotReachHere();
  return 0;
}


Bytecodes::SendType InterpretedIC::send_type() const {
  return Bytecodes::send_type(send_code());
}


Bytecodes::ArgumentSpec InterpretedIC::argument_spec() const {
  return Bytecodes::argument_spec(send_code());
}


void InterpretedIC::clear() {
  if (is_empty()) return;
  if (send_type() == Bytecodes::polymorphic_send) {
    // recycle PIC
    assert(second_word()->is_objArray(), "must be a pic");
    Interpreter_PICs::deallocate(objArrayOop(second_word()));
  }
Events:
remediation interpretedIC.cpp:153
assignment_where_comparison_intended interpretedIC.cpp:153