Sorry, to be clear I'm using "g++" in all compilations, I'm not using "gcc" at all. On Wed, 2013-09-11 at 17:40 -0400, Paul Smith wrote: > Hi all. I'm using GCC 4.8.1 that I built myself on Intel (GNU/Linux). > I'm seeing a strange behavior dealing with __attribute__((unused)) in a > C++ template. > > I have a macro UNUSED set to that value, and I've been using it (where > needed, typically when I need to save the value only for use in assert() > calls) as part of the type of a variable, like this: > > FooBar* UNUSED foo = something; > assert(foo); > > This is working fine, _except_ (apparently) in variables declared in > methods of a template class (weird!). In those situations the UNUSED > seems to be ignored if I write it like that. By "ignored" I mean that > in this form, gcc -O3 -D_NDEBUG will generate a warning that the > variable is not used. > > However if I change it to this: > > FooBar* foo UNUSED = something; > > then it works (as in, g++ does not generate this warning any longer). > > > Anyone have any thoughts about this? I can try to reduce this to a > repro case if there's interest. Or, am I just doing something wrong? >