public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99689] New: Initialized local variable becomes uninitialized after use
@ 2021-03-20 20:11 soren.soe at gonsoe dot com
  2021-03-20 20:11 ` [Bug c++/99689] " soren.soe at gonsoe dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: soren.soe at gonsoe dot com @ 2021-03-20 20:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99689

            Bug ID: 99689
           Summary: Initialized local variable becomes uninitialized after
                    use
           Product: gcc
           Version: 9.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: soren.soe at gonsoe dot com
  Target Milestone: ---

Created attachment 50439
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50439&action=edit
preprocessed file (*.i*) that triggers the bug

% g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/9/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,gm2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-9
--program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support
--enable-plugin --enable-default-pie --with-system-zlib
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release
--build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) 

% cat bug.cpp
#include <cassert>
#include <string>
#include <utility>
#include <vector>

using vec = std::vector<std::pair<std::string, std::string>>;

void
bad()
{
  vec v;
  v.emplace_back("abc", "def");
  v.emplace_back("abc", "def");
  v.emplace_back("abc", "def");
  v.emplace_back("abc", "def");
  v.emplace_back("abc", "def");

  unsigned int m = 0;
  for (auto& p : v)
    m = std::max<unsigned int>(m, p.first.length());

  assert(m == 3);
}

int main()
{
  bad();
  return 0;
}


% g++ -Wall -Wextra -O3 -std=c++14 bug.cpp 
% ./a.out 
a.out: bug.cpp:79: void bad(): Assertion `m == 3' failed.
Aborted (core dumped)

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-02-28  7:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-20 20:11 [Bug c++/99689] New: Initialized local variable becomes uninitialized after use soren.soe at gonsoe dot com
2021-03-20 20:11 ` [Bug c++/99689] " soren.soe at gonsoe dot com
2021-03-20 20:46 ` [Bug middle-end/99689] " pinskia at gcc dot gnu.org
2021-03-22  8:11 ` marxin at gcc dot gnu.org
2021-03-22  8:17 ` jakub at gcc dot gnu.org
2021-03-22 19:42 ` gnu at gonsoe dot com
2021-03-23  1:52 ` gnu at gonsoe dot com
2024-02-28  7:26 ` pinskia at gcc dot gnu.org
2024-02-28  7:51 ` pinskia 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).