public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/98373] New: [11 Repression] Bogus error: ‘symbuf’ may be used uninitialized at -O0
@ 2020-12-18 13:16 hjl.tools at gmail dot com
2020-12-18 15:36 ` [Bug middle-end/98373] " msebor at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: hjl.tools at gmail dot com @ 2020-12-18 13:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98373
Bug ID: 98373
Summary: [11 Repression] Bogus error: ‘symbuf’ may be used
uninitialized at -O0
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: hjl.tools at gmail dot com
Target Milestone: ---
Created attachment 49795
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49795&action=edit
A testcase
[hjl@gnu-cfl-2 gold]$ /usr/gcc-11.0.0-x32/bin/g++ -S /tmp/plugin.ii -W -Wall
/export/linux/src/binutils/binutils/gold/plugin.cc: In member function ‘void
gold::Sized_pluginobj<size, big_endian>::do_add_symbols(gold::Symbol_table*,
gold::Read_symbols_data*, gold::Layout*) [with int size = 32; bool big_endian =
false]’:
/export/linux/src/binutils/binutils/gold/plugin.cc:1400:33: warning: ‘symbuf’
may be used uninitialized [-Wmaybe-uninitialized]
1400 | elfcpp::Sym<size, big_endian> sym(symbuf);
| ^~~
In file included from /export/linux/src/binutils/binutils/gold/script.h:37,
from /export/linux/src/binutils/binutils/gold/layout.h:33,
from /export/linux/src/binutils/binutils/gold/plugin.cc:73:
/export/linux/src/binutils/binutils/gold/../elfcpp/elfcpp.h:1532:3: note: by
argument 2 of type ‘const unsigned char*’ to ‘elfcpp::Sym<size,
big_endian>::Sym(const unsigned char*) [with int size = 32; bool big_endian =
false]’ declared here
1532 | Sym(const unsigned char* p)
| ^~~
/export/linux/src/binutils/binutils/gold/plugin.cc:1399:17: note: ‘symbuf’
declared here
1399 | unsigned char symbuf[sym_size];
| ^~~~~~
/export/linux/src/binutils/binutils/gold/plugin.cc: In member function ‘void
gold::Sized_pluginobj<size, big_endian>::do_add_symbols(gold::Symbol_table*,
gold::Read_symbols_data*, gold::Layout*) [with int size = 64; bool big_endian =
false]’:
/export/linux/src/binutils/binutils/gold/plugin.cc:1400:33: warning: ‘symbuf’
may be used uninitialized [-Wmaybe-uninitialized]
1400 | elfcpp::Sym<size, big_endian> sym(symbuf);
| ^~~
In file included from /export/linux/src/binutils/binutils/gold/script.h:37,
from /export/linux/src/binutils/binutils/gold/layout.h:33,
from /export/linux/src/binutils/binutils/gold/plugin.cc:73:
/export/linux/src/binutils/binutils/gold/../elfcpp/elfcpp.h:1532:3: note: by
argument 2 of type ‘const unsigned char*’ to ‘elfcpp::Sym<size,
big_endian>::Sym(const unsigned char*) [with int size = 64; bool big_endian =
false]’ declared here
1532 | Sym(const unsigned char* p)
| ^~~
/export/linux/src/binutils/binutils/gold/plugin.cc:1399:17: note: ‘symbuf’
declared here
1399 | unsigned char symbuf[sym_size];
| ^~~~~~
[hjl@gnu-cfl-2 gold]$ /usr/gcc-11.0.0-x32/bin/g++ -S /tmp/plugin.ii -W -Wall
-O2
[hjl@gnu-cfl-2 gold]$
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/98373] [11 Repression] Bogus error: ‘symbuf’ may be used uninitialized at -O0
2020-12-18 13:16 [Bug middle-end/98373] New: [11 Repression] Bogus error: ‘symbuf’ may be used uninitialized at -O0 hjl.tools at gmail dot com
@ 2020-12-18 15:36 ` msebor at gcc dot gnu.org
2020-12-18 21:55 ` hjl.tools at gmail dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-12-18 15:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98373
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Ever confirmed|0 |1
Last reconfirmed| |2020-12-18
CC| |msebor at gcc dot gnu.org
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
The warning looks justified to me. Would you mind explaining why you think
it's invalid? (It seems like a basic expectation of any report.)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/98373] [11 Repression] Bogus error: ‘symbuf’ may be used uninitialized at -O0
2020-12-18 13:16 [Bug middle-end/98373] New: [11 Repression] Bogus error: ‘symbuf’ may be used uninitialized at -O0 hjl.tools at gmail dot com
2020-12-18 15:36 ` [Bug middle-end/98373] " msebor at gcc dot gnu.org
@ 2020-12-18 21:55 ` hjl.tools at gmail dot com
2020-12-18 22:38 ` [Bug middle-end/98373] [11 Repression] Bogus error: ‘symbuf’ may be used uninitialized at -O0 by r11-959 hjl.tools at gmail dot com
2020-12-18 23:40 ` msebor at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: hjl.tools at gmail dot com @ 2020-12-18 21:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98373
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |NEW
--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> ---
[hjl@gnu-cfl-2 gold]$ cat /tmp/foo.cc
template<int size>
struct Sym_data;
template<>
struct Sym_data<32>
{
unsigned char st_info;
unsigned char st_other;
};
template<>
struct Sym_data<64>
{
unsigned char st_info;
unsigned char st_other;
};
template<int size, bool big_endian>
class Sym
{
public:
Sym(const unsigned char* p)
: p_(reinterpret_cast<const Sym_data<size>*>(p))
{ }
private:
const Sym_data<size>* p_;
};
template<int size, bool big_endian>
class Sized_relobj_incr
{
private:
void do_add_symbols();
Sym<size, big_endian> *symbols_;
};
template<int size, bool big_endian>
Sym<size, big_endian> *
foo(Sym<size, big_endian> *);
template<int size, bool big_endian>
void
Sized_relobj_incr<size, big_endian>::do_add_symbols()
{
unsigned char symbuf[100];
Sym<size, big_endian> sym(symbuf);
Sym<size, big_endian>* res = foo(&sym);
this->symbols_ = res;
}
template
class Sized_relobj_incr<32, false>;
[hjl@gnu-cfl-2 gold]$ /usr/gcc-11.0.0-x32/bin/g++ -Wall -S /tmp/foo.cc
/tmp/foo.cc: In member function ‘void Sized_relobj_incr<size,
big_endian>::do_add_symbols() [with int size = 32; bool big_endian = false]’:
/tmp/foo.cc:47:25: warning: ‘symbuf’ may be used uninitialized
[-Wmaybe-uninitialized]
47 | Sym<size, big_endian> sym(symbuf);
| ^~~
/tmp/foo.cc:22:3: note: by argument 2 of type ‘const unsigned char*’ to
‘Sym<size, big_endian>::Sym(const unsigned char*) [with int size = 32; bool
big_endian = false]’ declared here
22 | Sym(const unsigned char* p)
| ^~~
/tmp/foo.cc:46:17: note: ‘symbuf’ declared here
46 | unsigned char symbuf[100];
| ^~~~~~
[hjl@gnu-cfl-2 gold]$
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/98373] [11 Repression] Bogus error: ‘symbuf’ may be used uninitialized at -O0 by r11-959
2020-12-18 13:16 [Bug middle-end/98373] New: [11 Repression] Bogus error: ‘symbuf’ may be used uninitialized at -O0 hjl.tools at gmail dot com
2020-12-18 15:36 ` [Bug middle-end/98373] " msebor at gcc dot gnu.org
2020-12-18 21:55 ` hjl.tools at gmail dot com
@ 2020-12-18 22:38 ` hjl.tools at gmail dot com
2020-12-18 23:40 ` msebor at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: hjl.tools at gmail dot com @ 2020-12-18 22:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98373
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[11 Repression] Bogus |[11 Repression] Bogus
|error: ‘symbuf’ may be used |error: ‘symbuf’ may be used
|uninitialized at -O0 |uninitialized at -O0 by
| |r11-959
--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> ---
It is caused by r11-959.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/98373] [11 Repression] Bogus error: ‘symbuf’ may be used uninitialized at -O0 by r11-959
2020-12-18 13:16 [Bug middle-end/98373] New: [11 Repression] Bogus error: ‘symbuf’ may be used uninitialized at -O0 hjl.tools at gmail dot com
` (2 preceding siblings ...)
2020-12-18 22:38 ` [Bug middle-end/98373] [11 Repression] Bogus error: ‘symbuf’ may be used uninitialized at -O0 by r11-959 hjl.tools at gmail dot com
@ 2020-12-18 23:40 ` msebor at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-12-18 23:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98373
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |INVALID
--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
Yes, but you still haven't explained why you think it's invalid.
The warning is by design as documented in the manual
Wmaybe-uninitialized
...
In addition, passing a pointer (or in C++, a reference) to an uninitialized
object to a const-qualified function argument is also diagnosed by this
warning. (-Wuninitialized is issued for built-in functions known to read the
object.) Annotating the function with attribute access (none) indicates that
the argument isn’t used to access the object and avoids the warning (see Common
Function Attributes).
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-12-18 23:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-18 13:16 [Bug middle-end/98373] New: [11 Repression] Bogus error: ‘symbuf’ may be used uninitialized at -O0 hjl.tools at gmail dot com
2020-12-18 15:36 ` [Bug middle-end/98373] " msebor at gcc dot gnu.org
2020-12-18 21:55 ` hjl.tools at gmail dot com
2020-12-18 22:38 ` [Bug middle-end/98373] [11 Repression] Bogus error: ‘symbuf’ may be used uninitialized at -O0 by r11-959 hjl.tools at gmail dot com
2020-12-18 23:40 ` msebor at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).