c++/7674: unjustified syntax error when a class contains a reference AND a pointer to member
ulrich.lauther@mchp.siemens.de
ulrich.lauther@mchp.siemens.de
Wed Aug 21 02:06:00 GMT 2002
>Number: 7674
>Category: c++
>Synopsis: unjustified syntax error when a class contains a reference AND a pointer to member
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Wed Aug 21 02:06:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Ulrich Lauther
>Release: Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2/specs Configured with: /usr/local/src/gcc-3.2/configure --enable-languages=c,c++ Thread model: posix gcc version 3.2
>Organization:
>Environment:
Linux i686, kernel 2.4.5
>Description:
The code attached compiled with g++ bug.C gives:
bug.C: In function `int main()':
bug.C:23: uninitialized const member `components::m_g'
>How-To-Repeat:
g++ bug.C
Where bug.C contains:
class hgraph_base {
public:
int foo;
};
class Hnode;
class components {
hgraph_base& m_g;
int Hnode::* m_node_nr;
public:
inline components(hgraph_base& pg) : m_g (pg) {
}
};
int main () {
hgraph_base base;
components bi(base);
return 0;
}
>Fix:
change hgraph_base& into hgraph_base* (and adapt the rest of the program) or comment out the line
int Hnode::* m_node_nr;
(this is - of course - not really a fix, but might hint at the problem)
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="bug.C"
Content-Disposition: inline; filename="bug.C"
class hgraph_base {
public:
int foo;
};
class Hnode;
class components {
hgraph_base& m_g;
int Hnode::* m_node_nr;
public:
inline components(hgraph_base& pg) : m_g (pg) {
}
};
int main () {
hgraph_base base;
components bi(base);
return 0;
}
More information about the Gcc-bugs
mailing list