1

I run the following with Code::Blocks

#include <iostream>

using namespace std;

int main()
{
    cout << "Hello, world !!!!!!!";
    return 0;
}

Now, there were some questions last night about how I knew my return value. I don't know if it's my version or not, but after the program runs on my version it says "Process returned v (0xv) execution time..." and etc where "v" is the returned value.

Now, here is what I'm asking, and this is as clear as I can make it.

When I run this, it returns value 1993075819 instead of 0. Also, the program doesn't run, all it does is show me the returned value.

Two things worthy of note:

  1. AVG pops up everytime I try and do this, and reports it as a trojan

  2. If I run the code without

    cout << "Hello, world!!!!";
    

It returns 0 like it should and AVG does not pop up

How can I fix this? (Code::Blocks 12.11)

Jason
  • 86,222
  • 15
  • 131
  • 146
user2154113
  • 401
  • 1
  • 6
  • 12
  • 1
    You have bigger problems. C++ is not your problem. The program as written returns 0, and any sensible operating system will let you access that return value and show you 0. Try a clean computer, or boot a Linux live CD, or use an online C++ compiler. – Kerrek SB Apr 23 '13 at 22:00
  • Presumably if you disable AVG but leave in `cout << "Hello world";` it also runs as it should? – john Apr 23 '13 at 22:01
  • You are not the first person with this problem, http://www.cplusplus.com/forum/beginner/67634/ – john Apr 23 '13 at 22:03
  • Or this one http://stackoverflow.com/questions/13144216/avg-detected-my-program-as-a-virus-whats-wrong-here – john Apr 23 '13 at 22:05

2 Answers2

0

The problem is not with your code, but with a false positive produced by AVG. The return code 1993075819 is because AVG intercepts the program and does not let it run.

You can report the false positive to AVG. Virus vendors are actually very good at fixing false positives reported by users. When I used to work at a company that produced lots of false positives (security related code that did funky things that triggered false positives), the turn-around was usually about a week.

In the mean time, if you use different compiler switches (e.g. optimized compile if it is not currently optimized or vice versa) there's a decent chance that the code you generate will not trigger the false positive.

You can also add your compiled program to the AVG safe list:

http://www.ehow.com/how_8192066_add-exceptions-avg.html

Eric J.
  • 147,927
  • 63
  • 340
  • 553
0

Disable AVG or configure it not to complain about your executable. For some reason the heuristics are misinterpreting some bit pattern in your executable as if it was a trojan and killing it before it starts. The result code that you get is from the intercepted program call (i.e. the antivirus) not from your program that is not even running.

David Rodríguez - dribeas
  • 204,818
  • 23
  • 294
  • 489