Bug 34229 - error on correct code
Summary: error on correct code
Status: RESOLVED DUPLICATE of bug 34238
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2007-11-25 20:29 UTC by Ralf W. Grosse-Kunstleve
Modified: 2007-12-03 03:15 UTC (History)
6 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:

reproducer (283 bytes, text/plain)
2007-11-25 20:30 UTC, Ralf W. Grosse-Kunstleve
reproducer preprocessed gzip'ed (95.25 KB, application/octet-stream)
2007-11-26 01:52 UTC, Ralf W. Grosse-Kunstleve

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf W. Grosse-Kunstleve 2007-11-25 20:29:54 UTC
  Fedora release 7 (Moonshine)
  Linux idle.lbl.gov #1 SMP Thu Sep 27 20:47:39 EDT 2007 x86_64
x86_64 x86_64 GNU/Linux

% g++ -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: /net/rosie/scratch2/rwgk/gcc_trunk/configure --prefix=/net/cci-filer1/vol1/tmp/rwgk/gcc_trunk_130411_x86_64_fc7 --enable-languages=c,c++,fortran --with-mpfr=/usr
Thread model: posix
gcc version 4.3.0 20071125 (experimental) (GCC)

I'll attach a small reproducer.

% g++ -c -fpermissive -I/usr/include/python2.5 used_but_not_defined.cpp
/usr/include/boost/type_traits/detail/cv_traits_impl.hpp:37: error: static data member 'boost::detail::cv_traits_imp<boost::reference_wrapper<boost::python::objects::<unnamed>::bind_return>*>::is_const' used, but not defined

Some data points:

svn revision 130341 didn't have this problem.
svn revision 130396 is broken already.
svn revision 130411 is still broken.

Comment 1 Ralf W. Grosse-Kunstleve 2007-11-25 20:30:57 UTC
Created attachment 14636 [details]
Comment 2 Andrew Pinski 2007-11-25 20:46:31 UTC
I don't think this is valid code.  There is no definition for the is_const part for the template where bind_return is in the anonymous namespace.  The code was diagnose before that date but it was not rejected because GCC did not diagnose the issue before.  We are diagnosing the invalid code now (which does not have to be diagnose according to the C++ standard).

Please read PR 34094 also.

Basically it comes down to (which is not rejected but should be but that is a different bug):
template <class a>  struct c
  static const bool t = 1;

namespace {
  struct b{};

int main(void)
  return c<b>::t;
Comment 3 Andrew Pinski 2007-11-25 20:47:03 UTC
Also please attach the preprocessed source.
Comment 4 Ralf W. Grosse-Kunstleve 2007-11-26 01:52:25 UTC
Created attachment 14638 [details]
reproducer preprocessed gzip'ed
Comment 5 Ralf W. Grosse-Kunstleve 2007-11-26 02:11:22 UTC
cc'ing David Abrahams since the original code is his.
Comment 6 Ralf W. Grosse-Kunstleve 2007-11-26 02:17:13 UTC
The patch below makes the Boost.Python compilation work again with
gcc svn trunk revision 130411. This solves my problem. :-)

The g++ change could be tough for people who have to keep using older
boost versions for one reason or another. I think it would be best
to accept the old code if -fpermissive is given, at least on the
gcc 4.3 line.

Index: function.cpp
--- function.cpp        (revision 41350)
+++ function.cpp        (working copy)
@@ -565,7 +565,11 @@
+namespace detail
+/* Cannot be anonymous namespace:
+     http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34094
+     http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34229
+ */
   struct bind_return
@@ -610,7 +614,8 @@
     function_call(PyObject *func, PyObject *args, PyObject *kw)
         PyObject* result = 0;
-        handle_exception(bind_return(result, static_cast<function*>(func), args, kw));
+        handle_exception(
+          detail::bind_return(result, static_cast<function*>(func), args, kw));
         return result;
Comment 7 Andrew Pinski 2007-12-03 03:15:59 UTC

*** This bug has been marked as a duplicate of 34238 ***