News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

CC fail after A class's static method called.

Started by nanyu, December 13, 2009, 01:51:37 AM

Previous topic - Next topic

nanyu


#include <iostream>

using namespace std;

class A
{
public:
    static void Test()
    {
    }
};

struct Soo
{
    int a;
};

Soo globalSoo;

int main()
{
    A::Test(); //remove this line, then cc work well.

    globalSoo.a = 9; //cc  allways do work well here

    Soo localeSoo;

    localeSoo.   // <-- cc do nothing

    return 0;
}


CC didn't work after I input "localSoo.".
After remove the line "A::Test()",  cc work well when I input  "localeSoo."

//////////////
Windows XP
Code::Blocks svn5911

blueshake

yes,you are right.you also can move the statement Soo localeSoo; to the top of A::Test(); since the A:: will affect the scope of localeSoo
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

nanyu

Quote from: blueshake on December 13, 2009, 03:08:31 AM
yes,you are right.you also can move the statement Soo localeSoo; to the top of A::Test(); since the A:: will affect the scope of localeSoo

Is it a bug of CC?

blueshake

Seem
Quote from: nanyu on December 13, 2009, 03:24:49 AM
Quote from: blueshake on December 13, 2009, 03:08:31 AM
yes,you are right.you also can move the statement Soo localeSoo; to the top of A::Test(); since the A:: will affect the scope of localeSoo

Is it a bug of CC?

Seem so.no time to check into it.
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

nanyu

I do the same thing in CodeLite, everything ok.  :(

MortenMacFly

Cannot reproduce with trunk. Please try the testing workspace, namely the project "function_decls". There is such a class inside with a static member function, as well as a global struct. I see all: The static (class) method, the methods after that as well as the struct and it's member variable.

So...?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

MortenMacFly

...even with the test case provided here: Works just fine... (see attached image)?!

[attachment deleted by admin]
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

oBFusCATed

You're missing the

    A::Test(); //remove this line, then cc work well.

line
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Jenna

Doesn't work for me either (trunk), it also does not work if I have std::cout before the declaration of localeSoo, std::endl doesn't matter.

MortenMacFly

Quote from: oBFusCATed on December 14, 2009, 04:28:31 PM
You're missing the

    A::Test(); //remove this line, then cc work well.

line
Quote from: jens on December 14, 2009, 04:57:42 PM
Doesn't work for me either (trunk), it also does not work if I have std::cout before the declaration of localeSoo, std::endl doesn't matter.
I did that, it still works (see image attached). Could you please try to reproduce with CC from trunk, and the testing project from trunk?

[attachment deleted by admin]
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

oBFusCATed

I'm not telling you that I've reproduced it :)
I've just spotted this accidentally.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Jenna

Quote from: MortenMacFly on December 14, 2009, 05:51:47 PM
Quote from: oBFusCATed on December 14, 2009, 04:28:31 PM
You're missing the

    A::Test(); //remove this line, then cc work well.

line
Quote from: jens on December 14, 2009, 04:57:42 PM
Doesn't work for me either (trunk), it also does not work if I have std::cout before the declaration of localeSoo, std::endl doesn't matter.
I did that, it still works (see image attached). Could you please try to reproduce with CC from trunk, and the testing project from trunk?
Quote from: jens on December 14, 2009, 04:57:42 PM
Doesn't work for me either (trunk), it also does not work if I have std::cout before the declaration of localeSoo, std::endl doesn't matter.


MortenMacFly

Quote from: jens on December 14, 2009, 06:12:56 PM
Quote from: jens on December 14, 2009, 04:57:42 PM
Doesn't work for me either (trunk), it also does not work if I have std::cout before the declaration of localeSoo, std::endl doesn't matter.
I realised that but thought it's a mistake because putting std::cout before the definition of the global variable (struct) results in invalid code. I mean: It's outside any function / method then...?!

Could yu just post what exactly I have to put into my main file to reproduce? Surely it should be valid code somehow.... otherwise I see no value in adding support to CC for parsing invalid code. :shock:
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Jenna

Quote from: MortenMacFly on December 14, 2009, 07:53:14 PM
Quote from: jens on December 14, 2009, 06:12:56 PM
Quote from: jens on December 14, 2009, 04:57:42 PM
Doesn't work for me either (trunk), it also does not work if I have std::cout before the declaration of localeSoo, std::endl doesn't matter.
I realised that but thought it's a mistake because putting std::cout before the definition of the global variable (struct) results in invalid code. I mean: It's outside any function / method then...?!

Could yu just post what exactly I have to put into my main file to reproduce? Surely it should be valid code somehow.... otherwise I see no value in adding support to CC for parsing invalid code. :shock:

I took nanyu's example from the first post.
localeSoo is a locale variable, that means it's perfectly legal to have std::cout before it.

There's no problem with global variables, but with variables, that are declared locally after the use of std::cout or the use of the static class method A::Test().

blueshake

#14
hi,guys
it is a bug as I knew.
you can see the debug log if turn the debugSmartSense on.
and you will find that the variable scope of localeSoo are different with/without statement A::Test();

with:
QuoteFindAIMatches() Looping 1 results
FindAIMatches() Match: 'localeSoo' (30032) : 'A::Soo'
BreakUpComponents() Breaking up 'A::Soo'
BreakUpComponents() Found component: 'A' (Namespace)
BreakUpComponents() Found component: 'Soo' (SearchText)
FindAIMatches() Looking for type: 'A::Soo' (2 components)
FindAIMatches() Now looking under 'Global namespace'
FindAIMatches() ----- FindAIMatches - enter -----

without

QuoteFindAIMatches() Looping 1 results
FindAIMatches() Match: 'localeSoo' (30032) : 'Soo'
BreakUpComponents() Breaking up 'Soo'
BreakUpComponents() Found component: 'Soo' (SearchText)
FindAIMatches() Looking for type: 'Soo' (1 components)
FindAIMatches() Now looking under 'Global namespace'
FindAIMatches() ----- FindAIMatches - enter -----


as I said above, the A:: will affect the scope of localeSoo
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?