help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

g++ warning for unsafe operation


From: mathieu
Subject: g++ warning for unsafe operation
Date: 13 Dec 2006 14:03:30 -0800
User-agent: G2/1.0

Hi there,

  I am looking for a warning in gcc that would warn me about
potentially dangerous operation, such as the one describe in (*). I
understand this is perfectly valid operation, but it looks to me like a
valid warning.

  I tried the following so far:

-Wall -Wextra -Wconversion -Wsign-compare

Thanks
-Mathieu

(*)
#include <vector>

int main()
{
  std::vector<int> v;
  int s = 0;
  for(unsigned int i = 0; i < v.size() - 1; ++i) // v.size() == 0
    {
    s += v[i] * v[i+1];
    }

  return 0;
}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]