unused attribute issue in C++ templates?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux