I have code which uses a preprocessor-heavy framework to generate some utility classes. Apparently, some of the macros result in the same friend
declaration being included twice in a class, something like this:
class Friendly {
// :::
friend class Bestie;
friend class Bestie;
// :::
};
When built with gcc (4.8.1), it generates a warning like
Bestie
is already a friend ofFriendly
[enabled by default]
I can't really see a use in this warning. I'm curious why it was included in gcc in the first place. However, as that is hardly answerable by the SO community, I'll state my question like this: What problems could arise from a friend
declaration being repeated, or what likely programmer errors could such an occurrence indicate?
The only problem I can think of which this could be hinting at is "You may have intended to write something else here instead of the same thing again, so I will helpfully warn you about this." However, in such case, the intended friendship would be missing, which would lead to an "access control violation" error in the code exercising the friendship, so I see little use of the warning itself.
Are there any potential problems I'm overlooking?