Jump to content
  • Advertisement
Sign in to follow this  
Sir Ementaler

Access violation when passing function to generic initialization list.

This topic is 871 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In AngelScript 2.31.1 WIP revision 2319, the following code causes an assertion failure, and if ignored, an access violation error:

funcdef bool Callback(int, int);
bool myGreaterThan(int a, int b) {
  return a > b;
bool myEquals(int a, int b) {
  return a == b;
bool myLessThan(int a, int b) {
  return a < b;
dictionary ops = {
  {"gt", @myGreaterThan},
  {"lt", @myLessThan},
  {"eq", @myEquals}

This error is exclusive to the $func type, i.e. won't occur if myCompare, myLessThan, and myEquals are assigned to handles of type Callback first and then those handles are passed to the initialization list. To remedy this temporarily script-side, I attempted making the following change to the ops definition:

dictionary ops = {
  {"gt", cast<Callback>(myGreaterThan)},
  {"lt", cast<Callback>(myLessThan)},
  {"eq", cast<Callback>(myEquals)}

This causes a different access violation without ever triggering an assertion failure. I didn't test whether the bugs are exclusive to initialization lists or also occur for generic function arguments.

Edited by Sir Ementaler

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!