GithubHelp home page GithubHelp logo

Incorrect handling of int128 values about arocc HOT 2 CLOSED

ehaas avatar ehaas commented on July 20, 2024
Incorrect handling of int128 values

from arocc.

Comments (2)

ehaas avatar ehaas commented on July 20, 2024

Possibly relevant:

void foo(void) {
    unsigned __int128 x = ((unsigned __int128)18446744073709551615UL)<< 64;
}
test.c:2:70: warning: overflow in expression; result is '-18446744073709551616' [-Winteger-overflow]
    unsigned __int128 x = ((unsigned __int128)18446744073709551615UL)<< 64;
                                                                     ^
1 warning generated.

(no diagnostics on clang)

from arocc.

Vexu avatar Vexu commented on July 20, 2024

Bug is in Type.signedness:

diff --git a/src/aro/Type.zig b/src/aro/Type.zig
index 7e691bc..1369d7b 100644
--- a/src/aro/Type.zig
+++ b/src/aro/Type.zig
@@ -609,7 +609,7 @@ pub fn signedness(ty: Type, comp: *const Compilation) std.builtin.Signedness {
     return switch (ty.specifier) {
         // zig fmt: off
         .char, .complex_char => return comp.getCharSignedness(),
-        .uchar, .ushort, .uint, .ulong, .ulong_long, .bool, .complex_uchar, .complex_ushort,
+        .uchar, .ushort, .uint, .ulong, .ulong_long, .uint128, .bool, .complex_uchar, .complex_ushort,
         .complex_uint, .complex_ulong, .complex_ulong_long, .complex_uint128 => .unsigned,
         // zig fmt: on
         .bit_int, .complex_bit_int => ty.data.int.signedness,

from arocc.

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.