Seeming unsigned int overflow?

11 views
Skip to first unread message

toff.tillman

unread,
Feb 27, 2017, 3:36:42 AM2/27/17
to Eiffel Users
Hi,

I have very little to none experience  with INTERNAL. But I ran across a difficulty with some code contributed by another. The difficulty seems to be coming from the Eiffel REFLECTOR class.

I constructed this test case to show the issue. Another class is being instantiated in the application, but gives the same error; I just used an instantiation of the TEST_NEW_INSTANCE class itself to illustrate without needing another class in the test case.

The test fails the new_instance_of postcondition, and the result seems to indicate an overflow.

Let me know if there's a better way to do this, the original code is a few years old now.

class
    TEST_NEW_INSTANCE

inherit
    INTERNAL

create
    make

feature {ANY} -- Initialization

    make
        local
            element_type_id: INTEGER_32
            new_inst: ANY
        do
            element_type_id := ({TEST_NEW_INSTANCE}).type_id
            print (element_type_id.out + "%N") -- shows 66722
            -- dynamic_type_set: POSTCONDITION_VIOLATION raised in next line
            new_inst := new_instance_of (element_type_id)
            -- Debugger shows Result.generating_type.type_id inside new_instance_of
            -- evaluates to 1186, not 66722 (N.B. 66722 - 1186 = 65536)
        end
end

Alexander Kogtenkov

unread,
Feb 27, 2017, 6:23:06 AM2/27/17
to eiffel...@googlegroups.com
The issue is with attachment marks: TEST_NEW_INSTANCE is attached by default, so the type ID corresponds to the version with an attached mark (that's why the value is above 65536).

Ideally the postcondition need to be updated. For the time being there are two workarounds, both preventing postcondition violation by getting rid of an attachment mark:

1. Use {detachable TEST_NEW_INSTANCE} instead of {TEST_NEW_INSTANCE}.

2. Use new_instance_of (detachable_type (element_type_id)) instead of new_instance_of (element_type_id).

Regards,
Alexander Kogtenkov


Понедельник, 27 февраля 2017, 11:36 +03:00 от "toff.tillman" <toff.t...@gmail.com>:

Chris Tillman

unread,
Feb 27, 2017, 12:41:13 PM2/27/17
to eiffel...@googlegroups.com
Thanks much Alexander.

--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/eiffel-users.
For more options, visit https://groups.google.com/d/optout.



--
Chris Tillman
Developer

Alexander Kogtenkov

unread,
Mar 1, 2017, 10:18:30 AM3/1/17
to eiffel...@googlegroups.com
The issue is fixed in the forthcoming release of EiffelStudio 17.05. Meanwhile those, who experience it, can replace the postcondition "dynamic_type_set" in {REFLECTOR}.new_instance_of with

    dynamic_type_set: attached_type (Result.generating_type.type_id) = attached_type (type_id)

and recompile affected precompiled libraries and projects from scratch.

Regards,
Alexander Kogtenkov


"'Alexander Kogtenkov' via Eiffel Users" <eiffel...@googlegroups.com>:

The issue is with attachment marks: TEST_NEW_INSTANCE is attached by default, so the type ID corresponds to the version with an attached mark (that's why the value is above 65536).

Ideally the postcondition need to be updated. For the time being there are two workarounds, both preventing postcondition violation by getting rid of an attachment mark:

1. Use {detachable TEST_NEW_INSTANCE} instead of {TEST_NEW_INSTANCE}.

2. Use new_instance_of (detachable_type (element_type_id)) instead of new_instance_of (element_type_id).

Regards,
Alexander Kogtenkov


Reply all
Reply to author
Forward
0 new messages