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

Check type selection for sizes #5

Closed
elfring opened this issue Sep 6, 2013 · 4 comments
Closed

Check type selection for sizes #5

elfring opened this issue Sep 6, 2013 · 4 comments

Comments

@elfring
Copy link

elfring commented Sep 6, 2013

I guess that a few functions will not work correctly if they will get negative values.
How do you think about to replace any "int" parameter like "length" by the data type "size_t"?

@farindk
Copy link
Contributor

farindk commented Sep 6, 2013

No, that just hides errors and there is no reason to save this one bit. If some computation gives negative values, errors are obvious. If you use unsigned, they overflow and are more difficult to find.

@farindk farindk closed this as completed Sep 6, 2013
@elfring
Copy link
Author

elfring commented Sep 6, 2013

I am surprised that you do not like unsigned integers here. I would prefer their use at various places to make the software a bit safer by design.

@farindk
Copy link
Contributor

farindk commented Sep 6, 2013

Feel free to do so.
And then have fun with code like

for (uint32_t i=length-1;i>=0;i--) { ... }

2013/9/6 Markus Elfring notifications@github.com

I am surprised that you do not like unsigned integers here. I would prefer
their use at various places to make the software a bit safer by design.


Reply to this email directly or view it on GitHubhttps://github.com//issues/5#issuecomment-23928788
.

@elfring
Copy link
Author

elfring commented Sep 6, 2013

for (uint32_t i = length - 1; i >= 0; --i) { ... }

Would you like to point out that the data types "uint32_t" and "size_t" have got different value ranges eventually?

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