Skip to content

Assigning a pointer to _Bool should give a warning #9500

@sirainen

Description

@sirainen
mannequin
Bugzilla Link 9128
Version trunk
OS Linux

Extended Description

I'd expect this to give two warnings, but none is given:

_Bool foo(void) {
  _Bool x = (void *)0;
  return (void *)0;
}

Not having this warning already caused a bug in my program, so this makes _Bool type even worse to me than using "int" as the boolean type.

I guess this might be because C99 says:

"When any scalar value is converted to _Bool, the result is 0 if the value compares equal to 0; otherwise, the result is 1."

If -Wall isn't good enough place for this, maybe a new -Wstrict-bool? (Actually I'd prefer such warning to check for other things about booleans too, but that's another thing.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions