public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104081] New: Variable optimized out despite -Og
@ 2022-01-18  8:32 matthias at urlichs dot de
  2022-01-18  8:34 ` [Bug c++/104081] " matthias at urlichs dot de
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: matthias at urlichs dot de @ 2022-01-18  8:32 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104081
           Summary: Variable optimized out despite -Og
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: matthias at urlichs dot de
  Target Milestone: ---

I expect the optimizer, when confronted with "-Og", to keep my variables
debuggable.

(I also expect (of me) to not make terminally stupid mistakes like the one
exhibited here, but that's a different problem …)

// "data" is a std::string_view
(gdb) l
19                      if(data.length() == 0)
20                              throw_invalid("empty",data);
21              }
22              for (const auto& c : data) {
23                      if ('0' < c || '9' > c)
24                              throw_invalid("not a number",data);
25                      val = val*10 + c-'0';
26              }
27              if(neg)
28                      val = -val;
(gdb) p data
$1 = <optimized out>
(gdb) p c
$2 = <optimized out>
(gdb) q

Options: g++-12 -march=native -Og -g -xc++ -std=c++17 …

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

end of thread, other threads:[~2024-06-14  8:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-18  8:32 [Bug c++/104081] New: Variable optimized out despite -Og matthias at urlichs dot de
2022-01-18  8:34 ` [Bug c++/104081] " matthias at urlichs dot de
2022-01-18  8:37 ` [Bug middle-end/104081] " pinskia at gcc dot gnu.org
2022-01-18  8:51 ` matthias at urlichs dot de
2022-01-18  9:46 ` rguenth at gcc dot gnu.org
2022-01-18 10:13 ` matthias at urlichs dot de
2024-06-14  7:40 ` user202729 at protonmail dot com
2024-06-14  8:09 ` matthias at urlichs dot de

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).