Does this specific c++ code have undefined behavior? [on hold]











up vote
-6
down vote

favorite












In this code. It sets array's size 0. And we can't access it. So I think it has undefined behavior. Is it correct thinking?



int varname{};









share|improve this question













put on hold as unclear what you're asking by πάντα ῥεῖ, Konrad Rudolph, Matthieu Brucher, Robert Columbia, ekad Nov 10 at 13:19


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 3




    This doesn't even compile for me.
    – tkausl
    Nov 10 at 12:28






  • 1




    I think what you might be getting at is are zero sized arrays OK - herbsutter.com/2009/09/02/when-is-a-zero-length-array-okay
    – Jeff Foster
    Nov 10 at 12:29










  • This code can be compiled.
    – 張皓雨
    Nov 10 at 12:30










  • @張皓雨 Not with a conforming C++ compiler: “error: zero-size array 'varname'”. It’s allowed as an extension by various compilers but since it’s not covered by the C++ standard we can’t make assertions about its behaviour according to the standard.
    – Konrad Rudolph
    Nov 10 at 12:31








  • 2




    @張皓雨 "This code can be compiled." Nope, it can't be compiled
    – πάντα ῥεῖ
    Nov 10 at 12:32















up vote
-6
down vote

favorite












In this code. It sets array's size 0. And we can't access it. So I think it has undefined behavior. Is it correct thinking?



int varname{};









share|improve this question













put on hold as unclear what you're asking by πάντα ῥεῖ, Konrad Rudolph, Matthieu Brucher, Robert Columbia, ekad Nov 10 at 13:19


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 3




    This doesn't even compile for me.
    – tkausl
    Nov 10 at 12:28






  • 1




    I think what you might be getting at is are zero sized arrays OK - herbsutter.com/2009/09/02/when-is-a-zero-length-array-okay
    – Jeff Foster
    Nov 10 at 12:29










  • This code can be compiled.
    – 張皓雨
    Nov 10 at 12:30










  • @張皓雨 Not with a conforming C++ compiler: “error: zero-size array 'varname'”. It’s allowed as an extension by various compilers but since it’s not covered by the C++ standard we can’t make assertions about its behaviour according to the standard.
    – Konrad Rudolph
    Nov 10 at 12:31








  • 2




    @張皓雨 "This code can be compiled." Nope, it can't be compiled
    – πάντα ῥεῖ
    Nov 10 at 12:32













up vote
-6
down vote

favorite









up vote
-6
down vote

favorite











In this code. It sets array's size 0. And we can't access it. So I think it has undefined behavior. Is it correct thinking?



int varname{};









share|improve this question













In this code. It sets array's size 0. And we can't access it. So I think it has undefined behavior. Is it correct thinking?



int varname{};






c++ undefined-behavior






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 10 at 12:26









張皓雨

11




11




put on hold as unclear what you're asking by πάντα ῥεῖ, Konrad Rudolph, Matthieu Brucher, Robert Columbia, ekad Nov 10 at 13:19


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






put on hold as unclear what you're asking by πάντα ῥεῖ, Konrad Rudolph, Matthieu Brucher, Robert Columbia, ekad Nov 10 at 13:19


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 3




    This doesn't even compile for me.
    – tkausl
    Nov 10 at 12:28






  • 1




    I think what you might be getting at is are zero sized arrays OK - herbsutter.com/2009/09/02/when-is-a-zero-length-array-okay
    – Jeff Foster
    Nov 10 at 12:29










  • This code can be compiled.
    – 張皓雨
    Nov 10 at 12:30










  • @張皓雨 Not with a conforming C++ compiler: “error: zero-size array 'varname'”. It’s allowed as an extension by various compilers but since it’s not covered by the C++ standard we can’t make assertions about its behaviour according to the standard.
    – Konrad Rudolph
    Nov 10 at 12:31








  • 2




    @張皓雨 "This code can be compiled." Nope, it can't be compiled
    – πάντα ῥεῖ
    Nov 10 at 12:32














  • 3




    This doesn't even compile for me.
    – tkausl
    Nov 10 at 12:28






  • 1




    I think what you might be getting at is are zero sized arrays OK - herbsutter.com/2009/09/02/when-is-a-zero-length-array-okay
    – Jeff Foster
    Nov 10 at 12:29










  • This code can be compiled.
    – 張皓雨
    Nov 10 at 12:30










  • @張皓雨 Not with a conforming C++ compiler: “error: zero-size array 'varname'”. It’s allowed as an extension by various compilers but since it’s not covered by the C++ standard we can’t make assertions about its behaviour according to the standard.
    – Konrad Rudolph
    Nov 10 at 12:31








  • 2




    @張皓雨 "This code can be compiled." Nope, it can't be compiled
    – πάντα ῥεῖ
    Nov 10 at 12:32








3




3




This doesn't even compile for me.
– tkausl
Nov 10 at 12:28




This doesn't even compile for me.
– tkausl
Nov 10 at 12:28




1




1




I think what you might be getting at is are zero sized arrays OK - herbsutter.com/2009/09/02/when-is-a-zero-length-array-okay
– Jeff Foster
Nov 10 at 12:29




I think what you might be getting at is are zero sized arrays OK - herbsutter.com/2009/09/02/when-is-a-zero-length-array-okay
– Jeff Foster
Nov 10 at 12:29












This code can be compiled.
– 張皓雨
Nov 10 at 12:30




This code can be compiled.
– 張皓雨
Nov 10 at 12:30












@張皓雨 Not with a conforming C++ compiler: “error: zero-size array 'varname'”. It’s allowed as an extension by various compilers but since it’s not covered by the C++ standard we can’t make assertions about its behaviour according to the standard.
– Konrad Rudolph
Nov 10 at 12:31






@張皓雨 Not with a conforming C++ compiler: “error: zero-size array 'varname'”. It’s allowed as an extension by various compilers but since it’s not covered by the C++ standard we can’t make assertions about its behaviour according to the standard.
– Konrad Rudolph
Nov 10 at 12:31






2




2




@張皓雨 "This code can be compiled." Nope, it can't be compiled
– πάντα ῥεῖ
Nov 10 at 12:32




@張皓雨 "This code can be compiled." Nope, it can't be compiled
– πάντα ῥεῖ
Nov 10 at 12:32

















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues