Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 758805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:31:24+00:00 2026-05-14T15:31:24+00:00

I have a piece of templated code that is never run, but is compiled.

  • 0

I have a piece of templated code that is never run, but is compiled. When I remove it, another part of my program breaks.


First off, I’m a bit at a loss as to how to ask this question. So I’m going to try throwing lots of information at the problem.

Ok, so, I went to completely redesign my test project for my experimental core library thingy. I use a lot of template shenanigans in the library. When I removed the “user” code, the tests gave me a memory allocation error. After quite a bit of experimenting, I narrowed it down to this bit of code (out of a couple hundred lines):

void VOODOO(components::switchBoard &board) {   
     board.addComponent<using_allegro::keyInputs<'w'> >();
}

Fundementally, what’s weirding me out is that it appears that the act of compiling this function (and the template function it then uses, and the template functions those then use…), makes this bug not appear. This code is not being run. Similar code (the same, but for different key vals) occurs elsewhere, but is within Boost TDD code.

I realize I certainly haven’t given enough information for you to solve it for me; I tried, but it more-or-less spirals into most of the code base. I think I’m most looking for “here’s what the problem could be”, “here’s where to look”, etc. There’s something that’s happening during compile because of this line, but I don’t know enough about that step to begin looking.

Sooo, how can a (presumably) compilied, but never actually run, bit of templated code, when removed, cause another part of code to fail?


Error:

Unhandled exceptionat 0x6fe731ea (msvcr90d.dll) in Switchboard.exe:
0xC0000005: Access violation reading location 0xcdcdcdc1.

Callstack:

operator delete(void * pUser Data)
allocator< class name related to key inputs callbacks >::deallocate
vector< same class >::_Insert_n(...)
vector< " " >::insert(...)
vector<" ">::push_back(...)

It looks like maybe the vector isn’t valid, because _MyFirst and similar data members are showing values of 0xcdcdcdcd in the debugger. But the vector is a member variable…

Update: The vector isn’t valid because it’s never made. I’m getting a channel ID value stomp, which is making me treat one type of channel as another.


Update:

Searching through with the debugger again, it appears that my method for giving each “channel” it’s own, unique ID isn’t giving me a unique ID:

inline static const char channel<template args>::idFunction() {
    return reinterpret_cast<char>(&channel<CHANNEL_IDENTIFY>::idFunction);
};

Update2: These two are giving the same:

slaveChannel<switchboard, ALLEGRO_BITMAP*, entityInfo<ALLEGRO_BITMAP*>
slaveChannel<key<c>, char, push<char>

Sooo, having another compiled channel type changing things makes sense, because it shifts around the values of the idFunctions? But why are there two idFunctions with the same value?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:31:24+00:00Added an answer on May 14, 2026 at 3:31 pm

    you seem to be returning address of the function as a character? that looks weird. char has much smaller bit count than pointer, so it’s highly possible you get same values. that could reason why changing code layout fixes/breaks your program

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a piece of C# code that add the values of an enum
I have a piece of text, that I wish to show truncated, but when
I have a piece of code that look similar to this: <xsl:choose> <xsl:when test=some_test>
For example, I have a piece of code that's generating a SQL*Loader control file
I have the following piece of code which replaces template markers such as %POST_TITLE%
I have a piece of server-ish software written in Java to run on Windows
I have this piece of code (summarized)... AnsiString working(AnsiString format,...) { va_list argptr; AnsiString
I have a piece of XML that is structured similar to this: <root> <score
We have a piece of functionality that is used by several different applications (clients)
I have a piece of code looking like this : TAxis *axis = 0;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.