Bug 57317 - [4.8/4.9 Regression] bogus and unsuppressible warning: 'YYY' has a base 'ZZZ' whose type uses the anonymous namespace
Summary: [4.8/4.9 Regression] bogus and unsuppressible warning: 'YYY' has a base 'ZZZ'...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: 4.8.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-17 17:13 UTC by Paul Pluzhnikov
Modified: 2013-05-23 21:56 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Pluzhnikov 2013-05-17 17:13:15 UTC
Google reference: b/9004062

Quite similar, but not identical to PR 56641.

Test case:

// --- cut ---
# 1 "t.h"
template < typename T > struct integral_c {
  static const T value = 0;
};
struct is_reference:integral_c < bool > { };
template < class > struct is_function_ptr_helper { };
template < bool > struct is_function_chooser;

template <> struct is_function_chooser <0 >
{
  template < typename T > struct result_:is_function_ptr_helper < T * > { };
};

template < typename T > struct is_function_impl:is_function_chooser <
  is_reference::value >::result_ < T > { };

#5 "t.cc"
namespace
{
  class NonCloneable;
  void fn1 ()
  {
    is_function_impl < NonCloneable > i;
  }
}
// --- cut ---


Using current (r199023) trunk:

g++  -c t.ii 
t.h: In instantiation of 'struct is_function_chooser<false>::result_<{anonymous}::NonCloneable>':
t.h:13:32:   required from 'struct is_function_impl<{anonymous}::NonCloneable>'
t.cc:10:39:   required from here
t.h:10:34: warning: 'is_function_chooser<false>::result_<{anonymous}::NonCloneable>' has a base 'is_function_ptr_helper<{anonymous}::NonCloneable*>' whose type uses the anonymous namespace [enabled by default]



Richard Smiths says:

  I think GCC is upset that a type defined outside of the main source file
  has a template argument that has internal linkage.

  In principle, that's a valuable diagnostic: it's trying to tell you that
  every time you include that header, you're going to get a different type,
  and you're likely to have an ODR diagnostic.

  However, in this case, it's a false positive, because this happened
  while instantiating a template from the main source file (with a type
  defined in the main source file, no less).

In addition, this warning isn't suppressable via -Wno-... parameter.
Comment 1 Paolo Carlini 2013-05-17 17:55:23 UTC
Irrespective of the primary issue, in general giving names to warnings is a good idea: what about other compilers?
Comment 2 Jason Merrill 2013-05-20 16:03:46 UTC
Fixed the false positive for 4.8.1.
Comment 3 Paul Pluzhnikov 2013-05-23 18:12:52 UTC
(In reply to Jason Merrill from comment #2)
> Fixed the false positive for 4.8.1.

Did you mean "fixed on trunk" ?

On trunk I see

  2013-05-20  Jason Merrill  <jason@redhat.com>

        PR c++/57317
        * decl2.c (determine_visibility): Use PRIMARY_TEMPLATE_P to decide
        whether a template has its own args.

but nothing on 4_8-branch.

Can this be back-ported to 4.8?

Thanks,
Comment 4 Jason Merrill 2013-05-23 21:43:00 UTC
(In reply to Paul Pluzhnikov from comment #3)
> but nothing on 4_8-branch.

Look again; it's commit 199104 on gcc-4_8-branch.
Comment 5 Paul Pluzhnikov 2013-05-23 21:56:29 UTC
(In reply to Jason Merrill from comment #4)

> Look again; it's commit 199104 on gcc-4_8-branch.

I can see it now. Thanks for the fix!