Linkage of various const/static variables

前端 未结 3 606
清酒与你
清酒与你 2020-12-24 10:14

I have a few questions about the linkage from the following variables. By examples of 7.1.1/7 of C++03 and experimenting with compilers (Comeau, Clang and GCC), I came to th

3条回答
  •  滥情空心
    2020-12-24 10:29

    Having both (e) and (f) in the same namespace scope is simply invalid, by §7.1.1/7 "The linkages implied by successive declarations for a given entity shall agree.".

    This rule requires a diagnostic.

    However, at least Comeau Online does not diagnose the violation.

    Cheers & hth.,

    EDIT: He he, I looked up DR 426, as mentioned in another answer here, and it seems those who drafted the proposed resolution, making it UB instead of diagnosable, were not aware of §7.1.1/7. I'm not going to comment on the issue or even raise it in comp.std.c++ because I found the standardization work to be far too political and nonsensical (mumbo-jumbo arguments) for me. But either way, the code's not valid.

提交回复
热议问题