Skip to content

[BUG] No type safety when comparing two incompatible variables #817

Closed
@alexgb0

Description

@alexgb0

Describe the bug
No type safety when comparing two variables

To Reproduce
Steps to reproduce the behavior:

  1. Sample code - distilled down to minimal essentials please
main: () -> int = {
	number: int = 123;
	string: std::string = "test";

	std::cout << number > string;
}
  1. Command lines, including which C++ compiler you are using
cppfront -p main.cpp2 &&
g++ main.cpp -std=c++23 -I/root/cppfront/include/ -o main
  1. Expected result - what you expected to happen
    Some kind of error message saying you can't compare incompatible types
  2. Actual result/error
main.cpp:22:19:   required from here
/root/cppfront/include/cpp2util.h:1808:28: error: no match for ‘operator>’ (operand types are ‘std::basic_ostream<char>’ and ‘std::__cxx11::basic_string<char>’)
 1808 |     return CPP2_FORWARD(t) > CPP2_FORWARD(u);
          |                                              ^

Additional context
I know it is a stupid problem, but I didn't pay attention and I have to admit that it took me some time to realize where was the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions