Skip to content

[lldb] [windows] operator bool() const on struct not being resolved in breakpoint condition #132179

Open
@k4lizen

Description

@k4lizen

Using lldb and clang on 01f0425 using windows.

#include <iostream>

struct Boolish {
    operator bool() const { return false; }
};
int main() {
    Boolish bol;
    if (!(bool)bol) {
        puts("operator resolved correctly!");
    }
    puts("break");
    puts("done");
    return 0;
}

Compiling with latest clang++ main.cpp -g3 -o main.exe.
Running ./main.exe gives the expected:

operator resolved correctly!
break
done

But trying the condition in lldb gives:

[snip]
(lldb) breakpoint set -f main.cpp -l 11 --condition "!(bool)bol"
(lldb) run
Process 5476 stopped
* thread #1, stop reason = breakpoint 1.1
    frame #0: 0x00007ff7e3e57186 main.exe`main at main.cpp:52
   49       if (!(bool)bol) {
   50           puts("operator resolved correctly!");
   51       }
-> 52       puts("break");
   53       puts("done");
   54       return 0;
   55   }
error: stopped due to an error evaluating condition of breakpoint 1.1: "!(bool)bol"
Couldn't parse conditional expression:
error: Couldn't look up symbols:
  bool Boolish::operator bool(void)
Hint: The expression tried to call a function that is not present in the target, perhaps because it was optimized out by the compiler.

(lldb)

If we remove the const, everything works as expected.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions