[Bug c++/49369] New: typeof() strips const from member when used in const method

2011-06-10 Thread shawn.bohrer at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49369

   Summary: typeof() strips const from member when used in const
method
   Product: gcc
   Version: 4.6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: shawn.boh...@gmail.com


$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/home/software/gcc-4.6.0/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --prefix=/home/software/gcc-4.6.0
--with-gmp=/home/jhand/inst --with-mpfr=/home/jhand/inst
Thread model: posix
gcc version 4.6.0 (GCC)


$ cat typeof.cpp 
template 
class A
{
public:
A(Container& container) {}
};

class B {
protected:
int member;
};

class C: public B {
public:
int method() const;
};

int C::method() const {
A iter(B::member);
return 0;
}

int main()
{
return 0;
}


$ g++ -o typeof typeof.cpp 
typeof3.cpp: In member function 'int C::method() const':
typeof3.cpp:19:42: error: no matching function for call to 'A::A(const
int&)'
typeof3.cpp:19:42: note: candidates are:
typeof3.cpp:5:5: note: A::A(Container&) [with Container = int]
typeof3.cpp:5:5: note:   no known conversion for argument 1 from 'const int' to
'int&'
typeof3.cpp:2:7: note: A::A(const A&)
typeof3.cpp:2:7: note:   no known conversion for argument 1 from 'const int' to
'const A&'


A couple of additional notes.  I get the same error with gcc 4.4.3, 4.5.1, and
4.6.0.  I get the same error if I use decltype instead of typeof.  I can get it
to compile if I do not use the fully qualified name (B::member), however in my
real application I must use the fully qualified name.


[Bug c++/49369] typeof() strips const from member when used in const method

2011-06-10 Thread shawn.bohrer at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49369

--- Comment #2 from shawn.bohrer at gmail dot com 2011-06-10 20:20:11 UTC ---
(In reply to comment #1)
> can you use typeof(this->B::member) instead?

Yes this works for my application, thanks for the suggestion.  Surely this is
still a bug though correct?