Author Topic: CC fail after A class's static method called.  (Read 21476 times)

Offline nanyu

  • Almost regular
  • **
  • Posts: 188
  • nanyu
CC fail after A class's static method called.
« on: December 13, 2009, 01:51:37 am »
Code
#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

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: CC fail after A class's static method called.
« Reply #1 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
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?

Offline nanyu

  • Almost regular
  • **
  • Posts: 188
  • nanyu
Re: CC fail after A class's static method called.
« Reply #2 on: December 13, 2009, 03:24:49 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?

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: CC fail after A class's static method called.
« Reply #3 on: December 13, 2009, 11:01:52 am »
Seem
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?

Offline nanyu

  • Almost regular
  • **
  • Posts: 188
  • nanyu
Re: CC fail after A class's static method called.
« Reply #4 on: December 13, 2009, 02:05:33 pm »
I do the same thing in CodeLite, everything ok.  :(

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: CC fail after A class's static method called.
« Reply #5 on: December 14, 2009, 03:07:07 pm »
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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: CC fail after A class's static method called.
« Reply #6 on: December 14, 2009, 03:09:57 pm »
...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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: CC fail after A class's static method called.
« Reply #7 on: December 14, 2009, 04:28:31 pm »
You're missing the
Code
    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!]

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: CC fail after A class's static method called.
« Reply #8 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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: CC fail after A class's static method called.
« Reply #9 on: December 14, 2009, 05:51:47 pm »
You're missing the
Code
    A::Test(); //remove this line, then cc work well.
line
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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: CC fail after A class's static method called.
« Reply #10 on: December 14, 2009, 05:54:06 pm »
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!]

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: CC fail after A class's static method called.
« Reply #11 on: December 14, 2009, 06:12:56 pm »
You're missing the
Code
    A::Test(); //remove this line, then cc work well.
line
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?
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.


Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: CC fail after A class's static method called.
« Reply #12 on: December 14, 2009, 07:53:14 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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: CC fail after A class's static method called.
« Reply #13 on: December 14, 2009, 08:02:18 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().

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: CC fail after A class's static method called.
« Reply #14 on: December 15, 2009, 02:38:09 am »
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:
Quote
FindAIMatches() 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

Quote
FindAIMatches() 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
« Last Edit: December 15, 2009, 02:40:13 am by blueshake »
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?