Weird compiler bug ( comment affects compilation )

Hi,

I have run into a weird bug with compiling some C++ code. I am trying to forward declare a class using code like this:

CTestboard tb;

And it doesn't compile, but if I add a comment to the end that has an exclamation point, it does (nothing else is changed):

CTestboard tb; //!



I thought the compiler completely ignored comments as if they weren't even there...what could possibly be causing this?
What error are you getting when you don't have the comment in your file? It could be a misplaced comment somewhere else perhaps?
@xerxes1986
And it doesn't compile, but if I add a comment to the end that has an exclamation point, it does (nothing else is changed):

CTestboard tb; //!


It is very interesting what will be if you substitute the exclamation mark for an interrogative mark in the comment? :)
Last edited on
If you substitute any other character, it doesn't work. I tried using a ?

This is very strange...
Indeed very strange.........
closed account (zb0S216C)
xerxes1986 wrote:
"I am trying to forward declare a class using code like this:

CTestboard tb;"

That isn't a forward declaration, but a object declaration; the two are different. This is a forward declaration:

 
class CTestboard;

I'm surprised nobody pointed that out.

As for you error, I assumed it could be a digraph or trigraph, but no of them match. I suspect the problem is with the code itself, and not the comment. I don't think it's a bug, because my compiler doesn't care; even old GCC compilers accept it.

Wazzak
Topic archived. No new replies allowed.