Bugzilla – Bug 4163
Pragma unused and arrays
Last modified: 2013-07-04 13:08:31 PDT
With #pragma unused possible to create 0 bound arrays Code: arr[-1] #pragma unused arr generates an error: invalid array size (negative or zero) but code: arr[0] #pragma unused arr no error :( also it registers in debug section of the file (amxxdump failed to read and analyze it) P.S. Maybe: 1) remove from debug section symbols (with zero using) 2) also possible to do arr[1][], but it really useless... maybe restrict 1 bound arrays, or optimize :)
IMO #pragma unused should not exist.
It useful to suppress warnings on debug temporary variables.
That doesn't sound too useful. Either the variables shouldn't be there, or the warning should be entirely optional, pref'd off by default.
But that warning useful if we write smth like: stock kz_show_hud(id, r, g, b, Float:x, Float:y, const msg[]) { if(is_user_connected(id)) { set_hudmessage(r, g, b, -1.0, y, 0, 0.0, 3.0, 0.0, 0.0, 4); //etc without using of x } } Then it`ll say that x never used, so we can simplify function, and without warning we can miss such things... It should not be off by default. So, i think that #pragma unused has the right to live
I don't think that's a good use case. The compiler is being too aggressive. It is very common to have unused inparams in functions because the implementation can evolve to make them unnecessary, and compatibility has to be preserved. I don't think C/C++ compilers even warn about unused inparams by default anymore. My beef here is twofold. First, it doesn't seem meaningful to have (buggy) preprocessor markup for an analysis that has little benefit. If the entire goal is to tell you that you have an unused parameter somewhere, it makes more sense to turn this functionality off by default, and allow users to pass a "--warn-unused" option or something, to opt-in to a specific pedantic warning. Second, I don't like the fact that this is being done in the preprocessor - that's a gross hack. It seems more sensible to have an "unused" keyword/attribute that you affix to the parameter in the function declaration.
IMO it`s a great idea to have unused keyword/attribute (but not only in function declaration), this can fully replace pragma unused in more proper way... But in both ways it shouldn`t have bug with arr[0] declaration :) New keyword would be better, but not so many people will use it, and it`s really small enhancement.
I think all has said about this.