Bug 15028 - typdef int bool seems unsafe
Summary: typdef int bool seems unsafe
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Build (show other bugs)
Version: 4.16.0
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
: 12474 (view as bug list)
Depends on:
Reported: 2022-03-22 03:27 UTC by Andrew Bartlett
Modified: 2022-04-04 16:30 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Bartlett 2022-03-22 03:27:55 UTC
If we use 'typedef int bool' then this expression will evaluate differently. 

int main() {
	bool foo = (4 & 4);
	if (foo == true) {
	} else {

Bug filed so we can backport as this will likely catch someone out doing a backport otherwise.

_Bool which libreplace accepts, is in C99 per wikipedia, as is bool.
Comment 1 Stefan Metzmacher 2022-03-22 08:51:08 UTC
Did you actually saw problems related to this somewhere?
Comment 2 Andrew Bartlett 2022-03-22 08:55:37 UTC
No, but was writing code that came close and thought this could bite someone - probably me - later, so wanted to close it off.


came close, but is safe, but I felt like fixing it for an == true case.
Comment 3 Samba QA Contact 2022-03-23 12:32:04 UTC
This bug was referenced in samba master:

Comment 4 Stefan Metzmacher 2022-03-29 12:02:44 UTC
Fixed for 4.17
Comment 5 Björn Jacke 2022-04-04 16:30:16 UTC
*** Bug 12474 has been marked as a duplicate of this bug. ***