Thread: Advanced C++ Programming Error (Weird Bug) 11+ years of experience.

  1. #1
    Registered User
    Join Date
    Sep 2015
    Posts
    31

    Lightbulb Advanced C++ Programming Error (Weird Bug) 11+ years of experience.

    debug.h
    Code:
    #define juice_debug_removeallocated(a) juice::debug::RemoveAllocated(a)
    
    namespace juice
    {
        namespace debug
        {
            JUICE_CORE_LIB void RemoveAllocated(void* data);
        }
    }
    Code:
    std::cout << "V:"<<Evaluation[i]->Data[c].Value_References << std::endl;
    juice_debug_removeallocated(Evaluation[i]->Data[c].Value_References);

    std::cout<<"v...
    shows: V:0000019A007F27E0

    inside juice_debug_removeallocated, printing Evaluation[i]->Data[c].Value_References
    shows: 0000019A007F29A0

    juice_debug_removeallocated takes a void*, Evaluation[i]->Data[c].Value_References is a uint64_t*

    I really don't understand what's going on here. isn't uint64_t* equivalent to void*?

    What could be the issue? Very weird as this is the first time I experience something like this in C++ after 11 years of programming.
    Last edited by billboardplus; 08-07-2016 at 12:23 PM.

  2. #2
    Registered User
    Join Date
    Sep 2015
    Posts
    31
    I'm seeing a 448 bytes difference between both values. Compiled for x64

  3. #3
    Registered User
    Join Date
    Sep 2015
    Posts
    31
    Edit..problem not fixed. Did other tests and still having the same issues.
    Last edited by billboardplus; 08-07-2016 at 01:37 PM.

  4. #4
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    So... what does RemoveAllocated() do, exactly?
    Devoted my life to programming...

  5. #5
    Registered User
    Join Date
    Sep 2015
    Posts
    31
    Code:
    reserved::Allocated_Table_Locker.lock();
    std::cout << data << std::endl;
    std::map<void*, juice::string>::iterator it = reserved::Allocated_Table.find(data);
    if (it != reserved::Allocated_Table.end())
    {
        reserved::Allocated_Table.erase(it);
    }
    reserved::Allocated_Table_Locker.unlock();
    cout ("data") is printing something else then what is printed before that function is ran. This function is exported to a DLL.

  6. #6
    Registered User
    Join Date
    Sep 2015
    Posts
    31
    Well, I guess I have to start debugging the application in asm. I'll get back to you with an answer soon..

  7. #7
    Registered User
    Join Date
    Sep 2015
    Posts
    31
    Extremely disappointed in myself hahaha....That preprocessor function definition was not running where it was supposed to...

    The original code was:

    Code:
    #ifdef JUICE_DEBUG
    #define juice_debug_addallocated(a,b) juice::debug::AddAllocated(a, b)
    #define juice_debug_removeallocated(a) juice::debug::RemoveAllocated(a)
    #else
    #define juice_debug_addallocated(a,b)
    #define juice_debug_removeallocated(a)
    #endif
    JUICE_DEBUG was not defined correctly in all the source files or header files...Hopefully, things like that don't happen too often...

    Thanks for your time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Programming Experience
    By shoutatchickens in forum A Brief History of Cprogramming.com
    Replies: 40
    Last Post: 04-04-2008, 01:00 PM
  2. weird/advanced question about C
    By panfilero in forum C Programming
    Replies: 3
    Last Post: 09-27-2005, 05:56 AM
  3. Teach Yourself Programming in Ten Years - READ THIS
    By nickname_changed in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 09-21-2005, 05:04 PM
  4. Where will programming be in 30 years ?
    By mrpickle in forum A Brief History of Cprogramming.com
    Replies: 27
    Last Post: 01-08-2004, 05:42 AM
  5. Gaining Experience in C/C++ Programming
    By stevey in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 03-29-2002, 12:45 PM

Tags for this Thread