[Bug c++/32204] friend from global namespace in template class ignored

2012-03-26 Thread dpiepgrass at mentoreng dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32204

David Piepgrass  changed:

   What|Removed |Added

 CC||dpiepgrass at mentoreng dot
   ||com

--- Comment #3 from David Piepgrass  
2012-03-26 21:20:11 UTC ---
I have run into this bug or a similar bug while porting my code from MSVC to
GCC. I need to declare that a class in the global namespace is a friend of my
template class. However, I discovered that the bug still occurs if no templates
are involved. Here's my repro:

class Friend;
namespace Foo
{
class Base {
};
class Derived : protected Base {
friend class Friend;
};
}
class Friend {
void F(const Foo::Derived* data) const 
{
// error: 'Foo::Base' is an inaccessible base of 'Foo::Derived'
const Foo::Base* dataB = data;
}
};

The problem disappears if either (A) Derived is not in a namespace, or (B)
Friend is in a namespace (the forward declaration of Friend is required and, of
course, must be put in the namespace too).


[Bug c++/32204] friend from global namespace in template class ignored

2012-03-26 Thread dpiepgrass at mentoreng dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32204

--- Comment #4 from David Piepgrass  
2012-03-26 21:24:26 UTC ---
(In reply to comment #3) I forgot to mention my GCC version, 4.4.3 (the Windows
build that comes with the current Android SDK.)


[Bug c++/44811] non controllable bogus warning: right/left shift count is negative

2012-04-26 Thread dpiepgrass at mentoreng dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44811

David Piepgrass  changed:

   What|Removed |Added

 CC||dpiepgrass at mentoreng dot
   ||com

--- Comment #4 from David Piepgrass  
2012-04-26 18:02:34 UTC ---
What makes warnings like this really irritating is that templates get
instantiated more than once. I'm getting about two dozen of these warnings from
just two lines of template code, since the template is instantiated for many
integer values. And that's just from one cpp file; other cpp files give a
separate set of warnings (I'd consider using extern template, except that I
have to target MSVC9 too.)

Actually, GCC currently gives many thousand warnings for my project: it seems
nearly half of them come from these left/right shift warnings, and nearly half
also come from a couple dozen member functions of the form "Foo Foo() const {
... }" that my code contains, which never bothered MSVC.

The documentation of the diagnostic pragma
(http://gcc.gnu.org/onlinedocs/gcc-4.6.0/gcc/Diagnostic-Pragmas.html) doesn't
say how to disable all warnings... should this work?

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-w"
template uint64_t shift(uint64_t b) {
if (N > 0)
return b << N;
else
return b >> -N;
}
#pragma GCC diagnostic pop

It doesn't work for me, but it may just be my older GCC (4.4.3 for Google
Android). 4.4.3 complains about not supporting push/pop, but it doesn't
complain about -w even though it does not actually suppress any warnings.

Could I perhaps disable all warnings by default, and then use a pragma to
re-enable all warnings when the .cpp is reached?