Thread: weird things going on in my code

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    569

    weird things going on in my code

    so I've had this snippet of code amongst my 5000 line of code:

    Code:
    if (root->StmtDomain[1]->type == T_EXPR_ARRAY) 
    				{
    				isArrayAssign2Array = 1;
    				
    				isTaNodeForArr2Arr = 1;
    				if ( root->StmtDomain[1]->left->type ==  T_EXPR_INTCON && root->StmtDomain[1]->left->type !=  T_EXPR_CHARCON || root->StmtDomain[1]->left->type !=  T_EXPR_VARIABLE 
    							|| root->StmtDomain[1]->left->type !=  T_EXPR_ARRAY )
    					{ /* do nothing */ }
    					else
    					{
    					isArrayAssign2ArrayWithExpr = 1;
    					}
    				}
    the problem is that whenever I try to run this program and it executes this part of the code, especially the :

    Code:
    if (root->StmtDomain[1]->type == T_EXPR_ARRAY)
    the program just kind of freeze and does nothing

    when I change that to :

    Code:
    if (root->StmtDomain[1]->type == 6)

    it progress normally.. T_EXPR_ARRAY here is an element of a struct.. something like this:

    Code:
    typedef enum{
    
     T_EXPR_ARRAY
     ............
    
    } ExpType;
    Can someone please help me where to look for this? It used to work in the same way like this a few hours ago, however I modified some things and I forgot all of those I did...

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    That's not an element of a struct, it's an enum. Not the same thing.

    Are you sure that's where it's freezing? Either that means one of your pointers is invalid, or it's getting through here and hanging somewhere else. Although changing to 6 wouldn't change that. What does the else look like?

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    569
    Quote Originally Posted by tabstop View Post
    That's not an element of a struct, it's an enum. Not the same thing.

    Are you sure that's where it's freezing? Either that means one of your pointers is invalid, or it's getting through here and hanging somewhere else. Although changing to 6 wouldn't change that. What does the else look like?
    yes I am pretty sure that's where it occurs, at least when I try to remove that block of if statement the program can execute without going on and on... I really don't know how am I suppose to trace this 5k lines of code...

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    One line at a time.

    Alternatively, you can use a debugger of some kind (gdb / Visual studio debugger).

    And I don't see anything in the if -- but what about the else? And again, are you sure all your pointers are valid?

  5. #5
    Registered User
    Join Date
    Jan 2008
    Posts
    569
    yes I am pretty sure.. and I've tried to print stuffs at lines after that.. I've got another conclusion...

    when :

    root->StmtDomain[1]->type == T_EXPR_ADD then this weird things occur...

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    It can't really hang inside this if statement; there's three assignment statements and an if. (Well, I shouldn't say it can't; I would say it would be unlikely to.)

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by -EquinoX- View Post
    I really don't know how am I suppose to trace this 5k lines of code...
    That is why we have debuggers! You should never leave home without one.
    Visual Studio is, by far, IMHO, the simplest and most powerful debugger there ever was.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. weird errors
    By R3N3G4D3 in forum Windows Programming
    Replies: 0
    Last Post: 06-14-2005, 06:54 AM
  2. Weird code execution order problem
    By Syko in forum C Programming
    Replies: 2
    Last Post: 05-12-2005, 02:29 PM
  3. Weird things happening!!!!!!
    By korbitz in forum Windows Programming
    Replies: 4
    Last Post: 03-22-2004, 06:31 AM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 4
    Last Post: 01-16-2002, 12:04 AM