Skip to content

Conditional operator bugs #1008

Open
Open
@john-h-kastner

Description

@john-h-kastner

I've noticed two similar issue with conditional expressions. In both cases, clang does not believe the conditional is checked even though the branches are checked on their own.

void foo(void) {
  int a, b;
  _Ptr<int> c = 0 ? &a : &b;
}
z.c:3:17: error: expression has unknown bounds, cast to ptr<T> expects source to have bounds
  _Ptr<int> c = 0 ? &a : &b;
void f(void) {}
void g(void) {}
void bar(void) {
  _Ptr<void(void)> h = 0 ? f : g;
}
y.c:5:24: error: cannot guarantee operand of cast to checked function pointer type '_Ptr<void (void)>' is a function pointer
  _Ptr<void(void)> h = 0 ? f : g;
                       ^~~~~~~~~
1 error generated.

Metadata

Metadata

Assignees

Labels

priority:3This labels bugs that are not very critical but still need to be addressed.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions