public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/48593] New: Wrong return type when applying address operator to inherited, template dependend member, using a typedef
@ 2011-04-13 18:35 meinhard@uni-mainz.de
2011-04-14 8:04 ` [Bug c++/48593] " redi at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: meinhard@uni-mainz.de @ 2011-04-13 18:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48593
Summary: Wrong return type when applying address operator to
inherited, template dependend member, using a typedef
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: meinhard@uni-mainz.de
The following code should compile but does not. It works on any other compiler
I tried (Comeau, Intel and MSVC). It seems the espression "&(Super::data)" is
interpreted as a pointer-to-data-member. This interpretation cannot be correct,
because the braces would not be legal in that kind of expression.
A possible workaround is using "&(this->data)" instead.
Works as expected if done without templates.
Code:
template <typename T> struct foo
{
T data;
};
template<typename T> struct bar: public foo<T>
{
typedef foo<T> Super;
void some_func()
{
T* ptr = & (Super::data);
}
};
int main()
{
bar<int> b;
b.some_func();
}
Output:
$> g++ -v -Wall -Wextra test.cc
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.3-4ubuntu5'
--with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--enable-multiarch --enable-linker-build-id --with-system-zlib
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls
--enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc
--disable-werror --with-arch-32=i486 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)
COLLECT_GCC_OPTIONS='-v' '-Wall' '-Wextra' '-shared-libgcc' '-mtune=generic'
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/cc1plus -quiet -v -D_GNU_SOURCE test.cc
-D_FORTIFY_SOURCE=2 -quiet -dumpbase test.cc -mtune=generic -auxbase test -Wall
-Wextra -version -fstack-protector -o /tmp/ccqnK7Ea.s
GNU C++ (Ubuntu 4.4.3-4ubuntu5) version 4.4.3 (x86_64-linux-gnu)
compiled by GNU C version 4.4.3, GMP version 4.3.2, MPFR version 2.4.2-p1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/usr/include/x86_64-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/4.4
/usr/include/c++/4.4/x86_64-linux-gnu
/usr/include/c++/4.4/backward
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/include
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/include-fixed
/usr/include
End of search list.
GNU C++ (Ubuntu 4.4.3-4ubuntu5) version 4.4.3 (x86_64-linux-gnu)
compiled by GNU C version 4.4.3, GMP version 4.3.2, MPFR version 2.4.2-p1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 88858f45841827736473e527a4e9ab10
test.cc: In member function ‘void bar<T>::some_func() [with T = int]’:
test.cc:18: instantiated from here
test.cc:11: error: cannot convert ‘int foo<int>::*’ to ‘int*’ in initialization
test.cc:11: warning: unused variable ‘ptr’
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/48593] Wrong return type when applying address operator to inherited, template dependend member, using a typedef
2011-04-13 18:35 [Bug c++/48593] New: Wrong return type when applying address operator to inherited, template dependend member, using a typedef meinhard@uni-mainz.de
@ 2011-04-14 8:04 ` redi at gcc dot gnu.org
2011-07-01 17:44 ` jason at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2011-04-14 8:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48593
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid,
| |rejects-valid
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011.04.14 08:03:53
Ever Confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-04-14 08:03:53 UTC ---
confirmed, the standard is quite clear:
A pointer to member is only formed when an explicit & is used and its operand
is a qualified-id not enclosed
in parentheses. [ Note: that is, the expression &(qualified-id), where the
qualified-id is enclosed in
parentheses, does not form an expression of type “pointer to member.” ...]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/48593] Wrong return type when applying address operator to inherited, template dependend member, using a typedef
2011-04-13 18:35 [Bug c++/48593] New: Wrong return type when applying address operator to inherited, template dependend member, using a typedef meinhard@uni-mainz.de
2011-04-14 8:04 ` [Bug c++/48593] " redi at gcc dot gnu.org
@ 2011-07-01 17:44 ` jason at gcc dot gnu.org
2011-07-01 20:26 ` jason at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2011-07-01 17:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48593
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
CC| |jason at gcc dot gnu.org
AssignedTo|unassigned at gcc dot |jason at gcc dot gnu.org
|gnu.org |
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/48593] Wrong return type when applying address operator to inherited, template dependend member, using a typedef
2011-04-13 18:35 [Bug c++/48593] New: Wrong return type when applying address operator to inherited, template dependend member, using a typedef meinhard@uni-mainz.de
2011-04-14 8:04 ` [Bug c++/48593] " redi at gcc dot gnu.org
2011-07-01 17:44 ` jason at gcc dot gnu.org
@ 2011-07-01 20:26 ` jason at gcc dot gnu.org
2011-07-01 20:53 ` jason at gcc dot gnu.org
2013-03-07 8:47 ` paolo.carlini at oracle dot com
4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2011-07-01 20:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48593
--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2011-07-01 20:24:29 UTC ---
Author: jason
Date: Fri Jul 1 20:24:25 2011
New Revision: 175765
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175765
Log:
PR c++/48593
* pt.c (tsubst_qualified_id): Check PTRMEM_OK_P.
* tree.c (build_qualified_name): Set PTRMEM_OK_P.
* semantics.c (finish_parenthesized_expr): Clear PTRMEM_OK_P on
SCOPE_REF, too.
* cp-tree.h (PTRMEM_OK_P): Apply to SCOPE_REF, too.
(QUALIFIED_NAME_IS_TEMPLATE): Switch to lang flag 1.
Added:
trunk/gcc/testsuite/g++.dg/template/qualified-id4.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/cp-tree.h
trunk/gcc/cp/pt.c
trunk/gcc/cp/semantics.c
trunk/gcc/cp/tree.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/48593] Wrong return type when applying address operator to inherited, template dependend member, using a typedef
2011-04-13 18:35 [Bug c++/48593] New: Wrong return type when applying address operator to inherited, template dependend member, using a typedef meinhard@uni-mainz.de
` (2 preceding siblings ...)
2011-07-01 20:26 ` jason at gcc dot gnu.org
@ 2011-07-01 20:53 ` jason at gcc dot gnu.org
2013-03-07 8:47 ` paolo.carlini at oracle dot com
4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2011-07-01 20:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48593
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.7.0
--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2011-07-01 20:52:07 UTC ---
Fixed for 4.7.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/48593] Wrong return type when applying address operator to inherited, template dependend member, using a typedef
2011-04-13 18:35 [Bug c++/48593] New: Wrong return type when applying address operator to inherited, template dependend member, using a typedef meinhard@uni-mainz.de
` (3 preceding siblings ...)
2011-07-01 20:53 ` jason at gcc dot gnu.org
@ 2013-03-07 8:47 ` paolo.carlini at oracle dot com
4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-03-07 8:47 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48593
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |thierry.moreau at connotech
| |dot com
--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-03-07 08:47:18 UTC ---
*** Bug 56558 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-03-07 8:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-13 18:35 [Bug c++/48593] New: Wrong return type when applying address operator to inherited, template dependend member, using a typedef meinhard@uni-mainz.de
2011-04-14 8:04 ` [Bug c++/48593] " redi at gcc dot gnu.org
2011-07-01 17:44 ` jason at gcc dot gnu.org
2011-07-01 20:26 ` jason at gcc dot gnu.org
2011-07-01 20:53 ` jason at gcc dot gnu.org
2013-03-07 8:47 ` paolo.carlini at oracle dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).