[llvm-bugs] [Bug 37869] New: clang rejects legal code

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 19 23:27:10 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37869

            Bug ID: 37869
           Summary: clang rejects legal code
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zhonghao at pku.org.cn
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

The code is as follow:

//#include <iostream>
//using namespace std;
class Z {
public:
 // gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) allows to
 // write Z(int) while gcc version 2.97 20010205 wants Z(int j=43)
 Z(int);
 //void print ();
private:
 int i;
};
Z::Z(int j=43): i(j){}
//void Z::print(void){ cout << "Z : i= " << i << ".\n";}

int main()
{
 Z zobject=Z();
 //zobject.print();
}

clang++ rejects, and produces the following error messages:
error: addition of default argument on redeclaration makes this constructor a
default constructor
    Z::Z(int j=43): i(j){}
             ^ ~~
note: previous declaration is here

A previous version of gcc also rejects the code. The bug report is
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=2189

The gcc bug is fixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180620/30889900/attachment.html>


More information about the llvm-bugs mailing list