[Bug libstdc++/66902] _S_debug_messages is unneccessary public

2015-09-11 Thread persgray at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66902

--- Comment #5 from Vadim Zhukov  ---
(In reply to Jonathan Wakely from comment #4)
> Author: redi
> Date: Thu Sep  3 19:05:15 2015
> New Revision: 227466
> 
> URL: https://gcc.gnu.org/viewcvs?rev=227466&root=gcc&view=rev
> Log:
>   PR libstdc++/66902
>   * src/c++11/debug.cc (_S_debug_messages): Make array const.
> 
> Modified:
> trunk/libstdc++-v3/ChangeLog
> trunk/libstdc++-v3/src/c++11/debug.cc

I see that you removed "static" modifier in that commit, effectively making the
array in question exported again. Was it intended?

[Bug libstdc++/66902] _S_debug_messages is unneccessary public

2015-09-11 Thread persgray at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66902

--- Comment #7 from Vadim Zhukov  ---
(In reply to Jonathan Wakely from comment #6)
> 3.5 [basic.link]:
> 
> -3-  A name having namespace scope (3.3.6) has internal linkage if it is the
>  name of
>   — a variable, function or function template that is explicitly declared
> static; or,
>   — a variable of non-volatile const-qualified type that is neither
> explicitly declared extern nor previously declared to have external
> linkage; or
>   — a data member of an anonymous union.
> 
> The first bullet applied when it was explicitly declared static and the
> second bullet applies now that it is a const-qualified type at namespace
> scope. In both cases it has internal linkage, so you should not see a global
> symbol and should not get the warning.

Sorry, I've missed that. Thank you for clarification.

[Bug libstdc++/66902] New: _S_debug_messages is unneccessary public

2015-07-16 Thread persgray at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66902

Bug ID: 66902
   Summary: _S_debug_messages is unneccessary public
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: minor
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: persgray at gmail dot com
  Target Milestone: ---

Created attachment 36000
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36000&action=edit
proposed patch

The _S_debug_messages array is defined in libstdc++-v3/src/c++11/debug.cc
without "static" modifier, therefore becoming exported one. But it isn't used
in GCC anywhere outside the debug.cc source module. I found no users installed
in my laptop running many KDE-, GTK- and console-based programs.

On the other side, size of _S_debug_messages differs in different versions of
libstdc++. This way, while libstdc++ 4.9 is ABI-compatible with libstdc++ 4.2,
this particular symbol causes warnings from ld.so (at least here on OpenBSD).
Yes, libstdc++ versions are "mixed": some software requires decent versions of
GCC and doesn't build on the base one (4.2.1); therefore, such software gets
built and linked with GCC 4.9 (as of now), and libstdc++ 4.9 is forced to be
searched for symbols before libstdc++ 4.2. This works in general, but there is
a nasty warning produced:

WARNING: symbol(_ZN11__gnu_debug17_S_debug_messagesE) size mismatch, relink
your program

This happens because _S_debug_messages contains different number of strings in
different libstdc++ versions.

Since there is no real reason to keep _S_debug_messages public, I propose
making it static. There is an interface for accessing this array:

  const _Error_formatter&
  _Error_formatter::_M_message(_Debug_msg_id __id) const
  { return this->_M_message(_S_debug_messages[__id]); }

So the lack of "static" keyword looks like a simple overlook problem.

The attached patch simply adds "static" keyword. I've been running with this
patch for many weeks without any problem on OpenBSD/amd64.