c++ - When is "already a friend" warning useful? -


i have code uses preprocessor-heavy framework generate utility classes. apparently, of macros result in same friend declaration being included twice in class, this:

class friendly {   // :::   friend class bestie;   friend class bestie;   // ::: }; 

when built gcc (4.8.1), generates warning like

bestie friend of friendly [enabled default]

i can't see use in warning. i'm curious why included in gcc in first place. however, hardly answerable community, i'll state question this: what problems arise friend declaration being repeated, or programmer errors such occurrence indicate?

the problem can think of hinting @ "you may have intended write else here instead of same thing again, helpfully warn this." however, in such case, intended friendship missing, lead "access control violation" error in code exercising friendship, see little use of warning itself.

are there potential problems i'm overlooking?

i dont think usefull declare friend class many times. think bug reported , think have provided work around. better declare friend class @ once , should avod duplication later. check this

i think warning inform user has written redundant code many times of no use. else dont think there use of warning. why of programmers reported bug.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -