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

Assert in mtproto-utils.c line 101 #100

Open
gurelkaynak opened this issue Mar 31, 2016 · 6 comments
Open

Assert in mtproto-utils.c line 101 #100

gurelkaynak opened this issue Mar 31, 2016 · 6 comments

Comments

@gurelkaynak
Copy link

Hello,

I encountered the assert(0) in mtproto-utils.c line 101. It says "As long as nobody ever uses this code, assume it is broken."

I had to remove the assert and it worked fine. I guess it's ok to remove it?

gurelkaynak added a commit to gurelkaynak/tgl that referenced this issue Mar 31, 2016
@BenWiederhake
Copy link
Contributor

Interesting. The original code there was horribly broken (instant segfault). The current version is from me, in the hope of being somewhat okay. However, I don't know of any platform that has 32-bit long but 64-bit long long, so I assumed that this check was pointless anyway.

Could you please explain what's going on with your platform? (I'll post some code to determined your sizeofs in a moment.)

@BenWiederhake
Copy link
Contributor

Code to test it (you may need to write llu instead of lu):

#include <stdio.h>

int main() {
#define SAY(x) printf("sizeof(" #x ") = %lu\n", sizeof(x))
  SAY(int);
  SAY(long);
  SAY(long long);
  SAY(unsigned int);
  SAY(unsigned long);
  SAY(unsigned long long);
  return 0;
}

Here's the output on AMD64:

$ gcc -Wall -Wextra -pedantic -O2 -g -o say_sizeof say_sizeof.c
$ ./say_sizeof 
sizeof(int) = 4
sizeof(long) = 8
sizeof(long long) = 8
sizeof(unsigned int) = 4
sizeof(unsigned long) = 8
sizeof(unsigned long long) = 8
$

What platform are you using? What does it say there?

@BenWiederhake
Copy link
Contributor

Btw: You may also want to delete the comment Here be dragons (no longer untested, if you say it works) and the comments in ull2BN

gurelkaynak added a commit to gurelkaynak/tgl that referenced this issue Mar 31, 2016
@gurelkaynak
Copy link
Author

I'm on i686, Ubuntu 14.04 on virtualbox. My output is like this:

sizeof(int) = 4
sizeof(long) = 4
sizeof(long long) = 8
sizeof(unsigned int) = 4
sizeof(unsigned long) = 4
sizeof(unsigned long long) = 8

I removed the other code too, works fine for me. Maybe it's because of virtualbox or something, it is indeed weird.

@BenWiederhake
Copy link
Contributor

Not weird, I just thought that i686 worked differently (specifically I always thought that long was 8 bytes there).

So yeah, I'd like to green-light this PR. However, please note that @vysheng seems very busy; I've been waiting for him to merge #94 and #98 for quite a while.

@gurelkaynak
Copy link
Author

I thought that too :) Thank you, we'll wait for @vysheng then.

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