the_commentor's blog

By the_commentor, history, 2 years ago, In English

TLDR; Would like to use -Wall -Wextra -O2 flags without the warnings interrupting CPH testcases.


Recently, I installed VSCode and was too lazy to set up warning flags. But it came back to bite me and I failed to solve a problem due to an avoidable bug if I had the -Wall flag.

I then proceeded to set up the flags in CPH, but soon noticed an issue. The warnings would stop the testcases from providing an output even if the code was perfectly fine.

Take this following code for example

#include <bits/stdc++.h>
using namespace std;

int main() {
    for (int i = 0; i < 5; i++) cout << i << " "; cout << endl;
    for (int i = 5; i < 9; i++) cout << i << " "; cout << endl;
}

This should output

0 1 2 3 4
5 6 7 8 9

But the compiler thinks that the user meant to add cout << endl; inside the for loop and raises a warning. But this stops CPH from running the testcase, and there is no output.

This is pretty annoying, especially if you're code is just fine.

Are there any workarounds to this issue?

Thanks and regards,
The Commentor

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it