Tom de Vries 5a99adb860 [gdb/build] Fix Wmaybe-uninitialized in gdb/ui-style.h
When building CFLAGS/CXXFLAGS="-O2 -g -Wall" and gcc 4.8.5, we run into:
...
src/gdb/cli/cli-style.c:154:42: warning: '*((void*)&<anonymous> +8)' \
  may be used uninitialized in this function [-Wmaybe-uninitialized]
src/gdb/cli/cli-style.c:154:42: warning: '*((void*)&<anonymous> +9)' \
  may be used uninitialized in this function [-Wmaybe-uninitialized]
src/gdb/cli/cli-style.c:154:42: warning: '*((void*)&<anonymous> +10)' \
  may be used uninitialized in this function [-Wmaybe-uninitialized]
...

The root cause is that the data members of class color, nested in struct
ui_file_style in gdb/ui-style.h:
...
    bool m_simple;
    int m_value;
    uint8_t m_red, m_green, m_blue;
...
are only partially initialized by this constructor:
...
    color (int c)
      : m_simple (true),
        m_value (c)
    {
      gdb_assert (c >= -1 && c <= 255);
    }
...
but the default copy constructor will copy all the fields.

The member m_simple acts as a discriminant, to indicate which other members
are valid:
- m_value (with m_simple == true)
- m_red, m_green, m_blue (with m_simple == false)
So, we don't need storage for both m_value and m_red/m_green/m_blue at the
same time.

Fix this by wrapping the respective members in a union:
...
    bool m_simple;
    union
    {
      int m_value;
      struct
      {
       uint8_t m_red, m_green, m_blue;
      };
    };
...
which also fixes the warning.

Build and reg-tested on x86_64-linux.

gdb/ChangeLog:

2020-07-30  Tom de Vries  <tdevries@suse.de>

	PR build/26320
	* ui-style.h (struct ui_file_style::color): Wrap m_value and
	m_red/m_green/m_blue in a union.
2020-07-30 09:23:01 +02:00
2020-07-30 00:00:07 +00:00
2020-07-04 10:16:22 +01:00
2020-02-22 20:37:18 -05:00
2020-07-27 22:31:37 +09:30
2020-02-20 13:02:24 +10:30
2020-07-29 16:03:55 -04:00
2019-12-26 06:54:58 +01:00
2020-02-07 08:42:25 -07:00
2020-02-07 08:42:25 -07:00

		   README for GNU development tools

This directory contains various GNU compilers, assemblers, linkers, 
debuggers, etc., plus their support routines, definitions, and documentation.

If you are receiving this as part of a GDB release, see the file gdb/README.
If with a binutils release, see binutils/README;  if with a libg++ release,
see libg++/README, etc.  That'll give you info about this
package -- supported targets, how to use it, how to report bugs, etc.

It is now possible to automatically configure and build a variety of
tools with one command.  To build all of the tools contained herein,
run the ``configure'' script here, e.g.:

	./configure 
	make

To install them (by default in /usr/local/bin, /usr/local/lib, etc),
then do:
	make install

(If the configure script can't determine your type of computer, give it
the name as an argument, for instance ``./configure sun4''.  You can
use the script ``config.sub'' to test whether a name is recognized; if
it is, config.sub translates it to a triplet specifying CPU, vendor,
and OS.)

If you have more than one compiler on your system, it is often best to
explicitly set CC in the environment before running configure, and to
also set CC when running make.  For example (assuming sh/bash/ksh):

	CC=gcc ./configure
	make

A similar example using csh:

	setenv CC gcc
	./configure
	make

Much of the code and documentation enclosed is copyright by
the Free Software Foundation, Inc.  See the file COPYING or
COPYING.LIB in the various directories, for a description of the
GNU General Public License terms under which you can copy the files.

REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info
on where and how to report problems.
Description
Unofficial mirror of sourceware binutils-gdb repository. Updated daily.
Readme 897 MiB
Languages
C 50.6%
Makefile 22.6%
Assembly 13.2%
C++ 5.9%
Roff 1.5%
Other 5.6%