Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 314116

Summary: Comparing function types with empty parameter lists
Product: [Tools] CDT Reporter: Tom Longridge <tom.longridge>
Component: cdt-parserAssignee: Project Inbox <cdt-parser-inbox>
Status: RESOLVED INVALID QA Contact: Mike Kucera <mikekucera>
Severity: normal    
Priority: P3    
Version: 7.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Tom Longridge CLA 2010-05-24 10:13:36 EDT
Build Identifier: M20100211-1343

When the following function types are compared using CFunctionType's isSameType, they are deemed to be not the same because their parameter lists are different lengths.

void func()
void func(void)

The standard (6.7.5.3) says that the "special case of an unnamed parameter of type void as the only item in the list specifies that the function has no parameters". So I would argue that the implementation of isSameType is incorrect in this case.

Reproducible: Always
Comment 1 Markus Schorn CLA 2010-05-25 04:43:20 EDT
Different to how this works in C++, in C the declaration 'void func()' means that the parameter list is unspecified, which is different from 'void func(void)' meaning that the function has an empty parameter list.

For example:
void f1() {
  f1(1);   // This is ok.
}

void f2(void) {
  f2(1);   // This is a compile error
}