public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55535] New: Call to default constructor with overloaded subscript operator is interpreted as declaring/using array
@ 2012-11-29 21:01 niels at penneman dot org
2012-11-29 21:07 ` [Bug c++/55535] " niels at penneman dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: niels at penneman dot org @ 2012-11-29 21:01 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55535
Bug #: 55535
Summary: Call to default constructor with overloaded subscript
operator is interpreted as declaring/using array
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: niels@penneman.org
gcc version:
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.0-alpha20121125/g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.8.0-alpha20121125/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-4.8.0_alpha20121125/work/gcc-4.8-20121125/configure
--prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.0-alpha20121125
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-alpha20121125/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-alpha20121125
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-alpha20121125/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-alpha20121125/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-alpha20121125/include/g++-v4
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec
--disable-fixed-point --with-ppl --with-cloog --disable-ppl-version-check
--with-cloog-include=/usr/include/cloog-ppl --enable-lto --enable-nls
--without-included-gettext --with-system-zlib --enable-obsolete
--disable-werror --enable-secureplt --enable-multilib
--with-multilib-list=m32,m64 --enable-libmudflap --disable-libssp
--enable-libgomp
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-alpha20121125/python
--enable-checking=release --disable-libgcj --disable-libquadmath
--enable-languages=c,c++ --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all
--with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo
4.8.0_alpha20121125'
Thread model: posix
gcc version 4.8.0-alpha20121125 20121125 (experimental) (Gentoo
4.8.0_alpha20121125)
====================
Command and output:
$ g++ -fsyntax-only -Wall -Wextra voodoo.cxx
voodoo.cxx: In function ‘void func()’:
voodoo.cxx:12:20: error: size of array has non-integral type ‘Empty’
(Voodoo()[Empty()]) | Empty();
^
voodoo.cxx:12:20: error: ‘type name’ declared as function returning an array
voodoo.cxx:12:20: error: size of array has non-integral type ‘Empty’
voodoo.cxx:12:20: error: ‘type name’ declared as function returning an array
====================
Full source code of 'voodoo.cxx':
struct Empty {};
struct Voodoo
{
Empty operator [](Empty);
};
void func()
{
(Voodoo()[Empty()]);
}
====================
It looks like gcc sees the type name (call to default constructor) followed by
the subscript operator as using or declaring an array. Without the parentheses
around "Voodoo()[Empty()]" makes the error go away. I don't see why the
parentheses should cause functionally different behaviour.
Because of that, and because the code passes syntax checking with clang 3.1,
icc 13 and armcc, I assume it's just something odd in g++. I am however not
100% sure that the above code conforms to the C++ standard, simply because I'm
not sure where to start looking.
While the above example looks useless the code has been extracted and
simplified from a >100k LOC boost/spirit-based parser where it did make sense.
Compiling this code also fails on 4.5.4, 4.6.3 and 4.7.2.
Note: (ancient) bug #13503 came up in 'possible duplicates' and looks slightly
related
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13503
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-06-26 19:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-29 21:01 [Bug c++/55535] New: Call to default constructor with overloaded subscript operator is interpreted as declaring/using array niels at penneman dot org
2012-11-29 21:07 ` [Bug c++/55535] " niels at penneman dot org
2012-11-29 21:19 ` paolo.carlini at oracle dot com
2014-06-26 19:24 ` 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).