🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Access violation when passing function to generic initialization list.

Started by
2 comments, last by Sir Ementaler 8 years, 1 month ago

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.

Advertisement

Thanks. I'll need to investigate this.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I've fixed this in revision 2321.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Thanks!

This topic is closed to new replies.

Advertisement