Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22002

Zero-initialized, unnamed, temporary unsigned int

$
0
0

Am I right to interpret unsigned int{}; as zero-initialization of a temporary unsigned int without a name in the contexts provided below? The example does not work with clang or gcc, but compiles fine in Visual Studio: https://godbolt.org/z/LYWCCN

int ifun(int value) {
    return value * 10;
}

unsigned int uifun(unsigned int value) {
    return value * 10u;
}

int main() {
    // does not work in gcc and clang
    unsigned int{};
    unsigned int ui = uifun(unsigned int{});

    // works with all three compilers, also unsigned{}; works
    int{};
    int i = ifun(int{});
}

Viewing all articles
Browse latest Browse all 22002

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>