View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
---|---|---|---|---|---|---|---|---|---|
0002745 | AI | AI | public | 2011-11-22 22:19 | 2011-11-24 23:06 | ||||
Reporter | AF | ||||||||
Assigned To | hoijui | ||||||||
Priority | normal | Severity | major | Reproducibility | always | ||||
Status | resolved | Resolution | fixed | ||||||
Summary | 0002745: VS2010/C90 incompatibility in C++ AI Wrapper in ::GetCustomParams() functions | ||||||||
Description | const char* keys[_size]; const char* values[_size]; _ret_int = bridged__UnitDef_getCustomParams(this->GetSkirmishAIId(), this->GetUnitDefId(), keys, values); Here the Visual Studio compiler cannot statically initialize the keys and values arrays ( wait the parameter is a const char** not a const char* could this not be clearer? ). What's more the semantics of this call do not follow const correctness, since the end result is a modification of a constant value ( constants aren't supposed to change ) | ||||||||
Additional Information | This code I've modified DOES compile: const char* keys = new char[_size]; const char* values = new char[_size]; _ret_int = bridged__UnitDef_getCustomParams(this->GetSkirmishAIId(), this->GetUnitDefId(), &keys, &values); Changes like this in a handful of other places makes Shard build under VS2010 | ||||||||
Tags | No tags attached. | ||||||||
Attached Files |
|
![]() |
|
AF (reporter) 2011-11-22 22:39 |
Note Shard isnt building, this just reduces the number of errors |
hoijui (reporter) 2011-11-23 11:02 Last edited: 2011-11-23 11:02 |
the code does follow const correctness. it are two arrays of constant strings. he arrays are not constant, but the strings are. nothing bad there (of course this would not compile on GCC, if it were incorrect). your code creates memory leak. ;-) but yeah, will change it. the root of the problem is that VS does only support C90, not C99 standard (have a guess how old that standard is already ;-) ). thanks for the report :-) |
hoijui (reporter) 2011-11-23 21:15 |
.. your code would also crash at runtime, as you have arrays of chars, instead of arrays of strings. |
AF (reporter) 2011-11-23 21:23 |
I never said my code worked, I just said it compiled =p How exactly it's fixed correctly is your call, though that function and those like it are all useless anyway and do nothing appreciable even if they did work as they're incomplete. |
hoijui (reporter) 2011-11-24 21:56 |
i already fixed this function locally, including what was missing (content of the for loop). little use lies in the debate, true. |
hoijui (reporter) 2011-11-24 23:06 |
resolved by: https://github.com/spring/spring/commit/7043612ddcc2e32122ca32991be148fa4fac2e3f |
![]() |
|||
Date Modified | Username | Field | Change |
---|---|---|---|
2011-11-22 22:19 | AF | New Issue | |
2011-11-22 22:39 | AF | Note Added: 0007651 | |
2011-11-23 10:59 | hoijui | Status | new => assigned |
2011-11-23 10:59 | hoijui | Assigned To | => hoijui |
2011-11-23 11:02 | hoijui | Note Added: 0007657 | |
2011-11-23 11:02 | hoijui | Note Edited: 0007657 | |
2011-11-23 11:03 | hoijui | Severity | block => major |
2011-11-23 21:15 | hoijui | Note Added: 0007661 | |
2011-11-23 21:23 | AF | Note Added: 0007662 | |
2011-11-24 21:56 | hoijui | Note Added: 0007692 | |
2011-11-24 22:33 | hoijui | Summary | VS2010 AI issue and Const correctness IN ::GetCustomParams() functions => VS2010/C90 incompatibility in C++ AI Wrapper in ::GetCustomParams() functions |
2011-11-24 23:06 | hoijui | Note Added: 0007693 | |
2011-11-24 23:06 | hoijui | Status | assigned => resolved |
2011-11-24 23:06 | hoijui | Resolution | open => fixed |