Coder Social home page Coder Social logo

Test 63_typedef fails about picoc HOT 9 OPEN

zsaleeba avatar zsaleeba commented on August 16, 2024
Test 63_typedef fails

from picoc.

Comments (9)

hellerve avatar hellerve commented on August 16, 2024

This is related to the size of int64/uint64 on your machine. The number within angle brackets designates the size of the number. It is expected to be 8 bytes, but is 4 bytes in size.

The tests expects a 64bit version OS, I guess. unsigned long is declared to be uint64_t at the top of the test, which does not hold true for every architecture.

Bottom line: The test is not failing because the software is not correct, but because of false internal premises.

Disclaimer: I am not affiliated with this software in any way, I just found your issue and thought I might clear things up a bit.

from picoc.

e8johan avatar e8johan commented on August 16, 2024

Yup, definitely something broken with the 64bit types. I just assumed that the interpreter would execute in a run-time that was independent of sizeof(unsigned long) for the host architecture. I don't have time to dig deeper here right now, but I guess the type definitions for the interpreter run-time, and not necessarily for the host platform, is the issue.

from picoc.

hellerve avatar hellerve commented on August 16, 2024

This is actually standard-conformant behaviour. unsigned long is not guaranteed to be 64 bits in any way. If you just typedef uint64_t as that, you will have a bad time.

from picoc.

e8johan avatar e8johan commented on August 16, 2024

Yup, the test is broken. I had a look in the code, and it seems that TypeUnsignedLong is defined in interpreter.h. Then in type.c, TypeSizeValue, an assumption is made that sizeof(unsigned long) <= sizeof(ALIGN_TYPE), which happens to be void * (defined in platform.h). Thus, it is broken.

I did a fugly fix to the test (using sizeof(x64) and sizeof(u64) to fake the output on non-64-bit platform). I'm preparing the pull request right now.

from picoc.

e8johan avatar e8johan commented on August 16, 2024

This is the fix mentioned in the previous comment: #8 .

from picoc.

galacticstudios avatar galacticstudios commented on August 16, 2024

I have a fork that fixes this problem (galacticstudios@abd7473). It implements picoc's 'long' as an int64_t, so that picoc's long will be 64 bits on every platform. I've tested on Windows (MS Visual C++ 2013 or newer) and on Linux. I've also fixed a bunch of compiler warnings on MSVC.

from picoc.

cgjordan avatar cgjordan commented on August 16, 2024

Anyone know if/when these fixes will make it into master?
I ran into this issue today on my Raspberry Pi 3 B, running 32-bit Raspbian 8.

root@raspberrypi:~# uname -r -m -o
4.4.13-v7+ armv7l GNU/Linux

from picoc.

zsaleeba avatar zsaleeba commented on August 16, 2024

Hey galacticstudios, want to send me a pull request with your fixes?

from picoc.

galacticstudios avatar galacticstudios commented on August 16, 2024

I've sent a pull request - I think. I haven't done it before so let me know if I did it wrong.

  • Bob

from picoc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.