public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/43522] New: 4.4 regression: Attempts to instantiate unnecessary code
@ 2010-03-25 18:04 georgeh at rentec dot com
2010-03-25 18:07 ` [Bug c++/43522] " georgeh at rentec dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: georgeh at rentec dot com @ 2010-03-25 18:04 UTC (permalink / raw)
To: gcc-bugs
Code:
---------------
template <bool x> struct tester;
template <> struct tester<true> { enum { value = 1 }; };
template <class T>
struct allow_double_instantiations {
static const bool value = false;
};
template <int Power>
class FixedPoint {
static const bool allow_double_instantiations = false;
typedef FixedPoint<Power> Self;
public:
FixedPoint(): mValue(0) {}
//Default copy c'tor, assignment op valid & useful.
Self &operator=(double const &d) {
mValue = sizeof(tester<Self::allow_double_instantiations>);
return *this;
}
int mValue;
};
void foo(FixedPoint<4> &);
int main() {
FixedPoint<4> x;
foo(x);
return 0;
}
template <>
FixedPoint<4> &FixedPoint<4>::operator=(double const &d) {
mValue = int(d);
return *this;
}
void foo(FixedPoint<4> &t) {
t = 13.5;
}
-------------
gcc 4.3.2 and earlier versions compile this without complaint; 4.4.3 dies with
test_fixedpoint.C: In member function `FixedPoint<Power>&
FixedPoint<Power>::operator=(const double&)':
test_fixedpoint.C:21: error: invalid application of `sizeof' to incomplete type
`tester<false>'
By my reading of the standard, the invalid definition of operator= should not
be attempted to be instantiated until line 43, where the valid template
specialization has been seen, and previous versions of g++ agree with me. Note
that in the original code, line 21 was a BOOST_STATIC_ASSERT and produced the
same result.
--
Summary: 4.4 regression: Attempts to instantiate unnecessary code
Product: gcc
Version: 4.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: georgeh at rentec dot com
GCC target triplet: i686-suse-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43522
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/43522] 4.4 regression: Attempts to instantiate unnecessary code
2010-03-25 18:04 [Bug c++/43522] New: 4.4 regression: Attempts to instantiate unnecessary code georgeh at rentec dot com
@ 2010-03-25 18:07 ` georgeh at rentec dot com
2010-03-25 18:08 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: georgeh at rentec dot com @ 2010-03-25 18:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from georgeh at rentec dot com 2010-03-25 18:07 -------
g++ -v output -- apologies:
Using built-in specs.
Target: i686-suse-linux
Configured with: ../../gcc-4.4.3/configure --enable-languages=c,c++,fortran --p
refix=/usr/local/products/gcc/4.4.3-32 --with-gnu-as --with-as=/usr/local/produ
cts/gcc/binutils-2.19-32/bin/as --with-gnu-ld --with-ld=/usr/local/products/gcc
/binutils-2.19-32/bin/ld --enable-threads=posix --enable-shared --enable-__cxa_
atexit --with-gmp=/usr/local/products/gcc/gmp-4.2.4-32 --with-mpfr=/usr/local/p
roducts/gcc/mpfr-2.3.2-32 --enable-libstdcxx-allocator=pool i686-suse-linux
Thread model: posix
gcc version 4.4.3 (GCC)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43522
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/43522] 4.4 regression: Attempts to instantiate unnecessary code
2010-03-25 18:04 [Bug c++/43522] New: 4.4 regression: Attempts to instantiate unnecessary code georgeh at rentec dot com
2010-03-25 18:07 ` [Bug c++/43522] " georgeh at rentec dot com
@ 2010-03-25 18:08 ` pinskia at gcc dot gnu dot org
2010-03-25 18:20 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-03-25 18:08 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2010-03-25 18:08 -------
So you are saying the standard thinks
FixedPoint<Power>::allow_double_instantiations is dependent.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43522
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/43522] 4.4 regression: Attempts to instantiate unnecessary code
2010-03-25 18:04 [Bug c++/43522] New: 4.4 regression: Attempts to instantiate unnecessary code georgeh at rentec dot com
2010-03-25 18:07 ` [Bug c++/43522] " georgeh at rentec dot com
2010-03-25 18:08 ` pinskia at gcc dot gnu dot org
@ 2010-03-25 18:20 ` pinskia at gcc dot gnu dot org
2010-03-25 18:37 ` [Bug c++/43522] [4.4 regression] " bangerth at gmail dot com
2010-03-25 18:47 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-03-25 18:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pinskia at gcc dot gnu dot org 2010-03-25 18:20 -------
I think that name is not dependent because or DR 224, see PR 29607.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43522
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/43522] [4.4 regression] Attempts to instantiate unnecessary code
2010-03-25 18:04 [Bug c++/43522] New: 4.4 regression: Attempts to instantiate unnecessary code georgeh at rentec dot com
` (2 preceding siblings ...)
2010-03-25 18:20 ` pinskia at gcc dot gnu dot org
@ 2010-03-25 18:37 ` bangerth at gmail dot com
2010-03-25 18:47 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: bangerth at gmail dot com @ 2010-03-25 18:37 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from bangerth at gmail dot com 2010-03-25 18:37 -------
(In reply to comment #2)
> So you are saying the standard thinks
> FixedPoint<Power>::allow_double_instantiations is dependent.
That is the correct question. We get the error message during
template parsing, not during template instantiation (otherwise
the error message would have "[with Power=4]"). So apparently
the compiler thinks that
Self::allow_double_instantiations
is non-dependent and so tries to instantiate the "tester" template
I think this is wrong: if you write it as Self::allow_double_instantiations
it should be dependent, whereas if you write it without the Self:: it
should be non-dependent.
Can someone double check whether this also happens with mainline?
W.
--
bangerth at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at redhat dot com,
| |bangerth at gmail dot com
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2010-03-25 18:37:17
date| |
Summary|4.4 regression: Attempts to |[4.4 regression] Attempts to
|instantiate unnecessary code|instantiate unnecessary code
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43522
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/43522] [4.4 regression] Attempts to instantiate unnecessary code
2010-03-25 18:04 [Bug c++/43522] New: 4.4 regression: Attempts to instantiate unnecessary code georgeh at rentec dot com
` (3 preceding siblings ...)
2010-03-25 18:37 ` [Bug c++/43522] [4.4 regression] " bangerth at gmail dot com
@ 2010-03-25 18:47 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-03-25 18:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from pinskia at gcc dot gnu dot org 2010-03-25 18:47 -------
>it should be non-dependent.
Except DR 224 changed that. See also PR 9634 comment #3 which shows that it is
not dependent at all.
And the trunk has the same behavior as 4.4.
So this code is invalid as DR 224 changed the wording such that name is non
dependent. Sorry to say that but it is just a weird case.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43522
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-03-25 18:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-25 18:04 [Bug c++/43522] New: 4.4 regression: Attempts to instantiate unnecessary code georgeh at rentec dot com
2010-03-25 18:07 ` [Bug c++/43522] " georgeh at rentec dot com
2010-03-25 18:08 ` pinskia at gcc dot gnu dot org
2010-03-25 18:20 ` pinskia at gcc dot gnu dot org
2010-03-25 18:37 ` [Bug c++/43522] [4.4 regression] " bangerth at gmail dot com
2010-03-25 18:47 ` pinskia at gcc dot gnu dot org
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).