Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_Bool test #428

Closed
Konstantin8105 opened this issue Dec 7, 2017 · 3 comments
Closed

_Bool test #428

Konstantin8105 opened this issue Dec 7, 2017 · 3 comments

Comments

@Konstantin8105
Copy link
Contributor

#include<stdio.h>
_Bool f(_Bool b){
        return  b;
}
int main(){
        _Bool b = 0;
        if (b){
                b++;
        }
        _Bool c = f(b);
        b = b + c;
        int i = (int)(b);
        printf("%d\n",i);
        return 0;
}
○ → gcc 2.c; ./a.out
0

Go:

func f(b bool) bool {
        return b
}
func main() {
        __init()
        var b bool = 0 != 0
        if b {
                func() bool {
                        b += 1
                        return b
                }()
        }
        var c bool = f(b)
        b = b+c
        var i int = map[bool]int{false: 0, true: 1}[map[bool]int{false: 0, true: 1}[(b)]]
        noarch.Printf([]byte("%d\n\x00"), i)
        return
}
○ → go build 2.go
# command-line-arguments
./2.go:190:6: cannot convert 1 to type bool
./2.go:190:6: invalid operation: b += 1 (mismatched types bool and int)
./2.go:195:7: invalid operation: b + c (operator + not defined on bool)
./2.go:196:45: cannot use map[bool]int literal[b] (type int) as type bool in map index
@Konstantin8105
Copy link
Contributor Author

Committee Draft — May 6, 2005
ISO/IEC 9899:TC2
par.6.2.5 6)

For each of the signed integer types, there is a corresponding (but different) unsigned
integer type (designated with the keyword unsigned) that uses the same amount of
storage (including sign information) and has the same alignment requirements. The type
_Bool and the unsigned integer types that correspond to the standard signed integer
types are the standard unsigned integer types. The unsigned integer types that
correspond to the extended signed integer types are the extended unsigned integer types.
The standard and extended unsigned integer types are collectively called unsigned integer types.

@Konstantin8105
Copy link
Contributor Author

Found in #67

@elliotchance
Copy link
Owner

Fixed in #445

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants