This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: dubious warning about unused object


>>>>> Edwards, Phil <pedwards@ball.com> writes:

 > + Another option would be to annotate the definition of Lock
 > + with a type attribute so that the compiler knows that Lock
 > + is a resource allocation class.  This seems like an appropriate
 > + solution; a patch would be welcome.

 > I think that the 'unused' attribute was documented as "not for use in
 > C++."

That only refers to parameter decls; in C++, you can just leave out the name.

 > I'm still learning about compiler internals, but is there an easy
 > explanation as to why

 > 	Lock    l (lockinfo) __attribute__ ((unused));
 > 	string  s;

 > wouldn't work around the problem?  Would the ctor/dtor calls get
 > accidentally "optimized" away or something?

Nope, that would also work.  It just seemed like a type attribute would be
more convenient, since you would only have to use it once.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]