&&& What is doing?

Asked 1 years ago, Updated 1 years ago, 122 views

If you compile the code below into the gcc -Wall /-Waddress option, warning: the address of ‘i’ will always evaluate as ‘true’ [-Waddress] It appears.

I don't know why it's coming up. I don't know what it means Is there anyone who can explain?

#include <stdio.h>

volatile int i;

int main()
{
    int c;

    for (i = 0; i < 3; i++) 
    {
         c = i &&& i;
         printf("%d\n", c);
    }

    return 0;
}

c c++ gcc-warning operator compiler-optimization

2022-09-22 22:30

1 Answers

c = i&&&i; = c = i&&i.

The address value of i is always true address of 'i' will always evaluate as 'true' warning.

However, if the unary operator & is overloaded from the user-defined type (if & is not an address value) You can produce different results.

It's not a good idea to use multiple operators It's better not to write like that


2022-09-22 22:30

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.