Open Quuxplusone opened 9 years ago
Bugzilla Link | PR22404 |
Status | REOPENED |
Importance | P normal |
Reported by | __vic (victor.dyachenko@protonmail.com) |
Reported on | 2015-01-30 07:42:31 -0800 |
Last modified on | 2015-02-03 12:30:01 -0800 |
Version | 3.5 |
Hardware | PC Linux |
CC | anton@korobeynikov.info, dblaikie@gmail.com, dgregor@apple.com, llvm-bugs@lists.llvm.org, rnk@google.com, sepavloff@gmail.com |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
Seems to work with ToT.
$ cat deriv.cpp
struct stat {
};
struct file_stat : public ::stat
{
file_stat(const struct ::stat &s) : ::stat(s) {}
};
int main()
{
struct ::stat s;
file_stat s2(s);
}
blaikie@blaikie-linux:/tmp/dbginfo$ clang++-tot deriv.cpp -fsyntax-only
blaikie@blaikie-linux:/tmp/dbginfo$
What is "clang++-tot"? Is it bug in 3.5? In which version was it fixed?
What about code like this?
struct stat {
};
void stat() {}
struct file_stat : public ::stat
{
file_stat(const struct ::stat &s) : ::stat(s) {}
};
int main()
{
struct ::stat s;
file_stat s2(s);
}
ToT means Top Of Trunk.
The second example indeed does not compile with ToT:
$ clang --version
clang version 3.7.0 (trunk 227734)
Target: x86_64-unknown-linux-gnu
Thread model: posix
$ clang ngs.cpp
ngs.cpp:7:43: error: member initializer 'stat' does not name a non-static data
member or base class
file_stat(const struct ::stat &s) : ::stat(s) {}
^~~~~~~
1 error generated.
The message looks invalid.
A reduced example:
$ cat t.cpp
int stat(const char *path, struct stat *buf);
struct stat {};
struct file_stat : public ::stat {
file_stat(const struct ::stat &s) : ::stat(s) {}
};
int main() {
struct ::stat s;
file_stat s2(s);
}
$ clang -cc1 t.cpp
t.cpp:4:41: error: member initializer 'stat' does not name a non-static data
member or base class
file_stat(const struct ::stat &s) : ::stat(s) {}
^~~~~~~
Lookup for ::stat finds the function, not the struct, and the elaborated type
"struct ::stat" is not legal in an initializer list. The typedef workaround
makes sense.