Defect Report: Multiple definitions of unused function/variable.

Defect Report: Multiple definitions of unused function/variable.

Post by Andrew Sch » Thu, 02 Dec 2010 11:18:26



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.
 
 
 

1. Defect Report: Associated function definitions of operator-> and operator[]

2. Defect Report [N2134]: Two unspecified function comparators in [function.objects]

The header <functional> synopsis in [function.objects]-20.5/2
contains the following two free comparison operator templates
for the function class template

template<class Function1, class Function2>
void operator==(const function<Function1>&, const
function<Function2>&);
template<class Function1, class Function2>
void operator!=(const function<Function1>&, const
function<Function2>&);

which are nowhere described.
I assume that they are relicts before the corresponding two
private and undefined member templates in the function
template (see 20.5.14.2 and 20.5.14.2.6) have been introduced.
The original free function templates should be removed, because
using an undefined entity would lead to an ODR violation of the
user.

Proposed resolution:

Remove the above mentioned two function templates from
the header <functional> synopsis (20.5/2)

Greetings from Bremen,

Daniel Krler


---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.yqcomputer.com/ ]

3. Defect Report: definition of static const data members

4. Defect Report: Definition of void parameter list differs from C

5. Defect report: inconsistent copy ctor definition (12.1.10)

6. Defect Report: Inconsistent definition of basic_regex constructor

7. [M68KNOMMU]: remove unused machdep variable definitions

8. How to avoid multiple definition of a variable by multiple inclusion of a header file

9. Defect Report: Jump past initialization of local static variable

10. Defect Report: Erroneous restrictions on variables which can be initialized by arbitrary expressions

11. Unused Variables and Unused Procedure

12. Defect report: usage of this outside function body

13. Defect Report: Using declaration cannot be a function declaration

14. Defect Report : Is it undefined if a function in the standard changes in parameters?

15. Defect Report: Multiple exceptions from connected shared_futu:get()?