[cfe-dev] -Wmismatched-tags in MacOSX's valarray

Christopher Jefferson chris at bubblescope.net
Thu Oct 21 04:06:36 PDT 2010


The problem is that valarray does (very reduced):


template<typename T>
struct _Array;

template<typename T>
struct valarray
{
  friend class _Array<T>;
};

valarray<int> a;

Note that the 'friend' declaration uses 'class', while the definition of _Array uses 'struct'.

This is probably a reasonable warning. it would be nice to suppress all warnings from system headers. There is an easy fix, but it would cause another difference between Mac OS X's copy of libstdc++ and the original one provided by g++, and wouldn't fix the issue on linux.

Chris


On 21 Oct 2010, at 10:09, Axel Naumann wrote:

> Hi,
> 
> compiling code that #includes <valarray> on MacOS X 10.6 triggers this:
> 
> warning: class  '_Array' was previously declared as a struct
> [-Wmismatched-tags]
> In file included from cint/cint/lib/dll_stl/G__cpp_valarray.cxx:7:
> In file included from ./cint/cint/lib/dll_stl/G__cpp_valarray.h:32:
> In file included from ./cint/cint/lib/dll_stl/vary.h:10:
> In file included from /usr/include/c++/4.2.1/valarray:539:
> /usr/include/c++/4.2.1/bits/valarray_after.h:62:24: note: in
> instantiation of template class 'std::valarray<unsigned long>' requested
> here
>      { return _M_index.size(); }
>                       ^
> In file included from cint/cint/lib/dll_stl/G__cpp_valarray.cxx:7:
> In file included from ./cint/cint/lib/dll_stl/G__cpp_valarray.h:32:
> In file included from ./cint/cint/lib/dll_stl/vary.h:10:
> In file included from /usr/include/c++/4.2.1/valarray:91:
> /usr/include/c++/4.2.1/bits/valarray_array.h:414:12: note: previous use
> is here
>    struct _Array
>           ^
> Is this warning correct? If so: can you get your colleagues down the
> hallway to fix it? ;-)

The problem is that 'struct _Array' is used in valarray_array.h, while 
> 
> And probably it's just me, but I have a hard time understanding the
> warning message itself: is it claiming that structs cannot be templated?
> Where is the "class _Array" that mismatches the "struct _Array"?
> 
> Cheers, Axel.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev





More information about the cfe-dev mailing list