Topic: Defect Report: Multiple definitions of unused function/variable.
Author: Andrew Schepler <aschepler@gmail.com>
Date: Wed, 1 Dec 2010 02:18:26 CST Raw View
The obvious intent of section 3.2 [basic.def.odr] is that non-inline
non-template functions and variables must have exactly one definition
if used or may have either zero or one definitions if not used, but no
requirement in the Standard actually says that multiple definitions
make the program ill-formed when the function or variable is not used.
Paragraph 1 forbids only multiple definitions in the same translation unit.
Paragraph 3 says "Every program shall contain exactly one definition
of every non-inline function or variable that is used in that program;
no diagnostic required." but says nothing about an unused non-inline
function or variable.
Paragraph 5 lists the cases where more than one definition for the
same entity is allowed, but does not say that declarations which are
not on that list may not have multiple definitions in the program.
--
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]