vlm / asn1c

The ASN.1 Compiler
http://lionet.info/asn1c/
BSD 2-Clause "Simplified" License
1.05k stars 558 forks source link

*Really* large integer constraints fail to compile #239

Open mouse07410 opened 7 years ago

mouse07410 commented 7 years ago

Current master

$ cat Test3.asn1
Test3 DEFINITIONS ::= BEGIN

Test3 ::= SEQUENCE 
{
    varianceA INTEGER (0..9892233720368547758079),
    varianceB INTEGER (0..9892233720368547758071)
}
END
$ asn1c -fwide-types -fbless-SIZE -gen-PER -gen-OER -pdu=Test3 -fcompound-names Test3.asn1
Compiled Test3.c
Compiled Test3.h
Copied /opt/local/share/asn1c/OPEN_TYPE.h   -> OPEN_TYPE.h
Copied /opt/local/share/asn1c/OPEN_TYPE.c   -> OPEN_TYPE.c
Copied /opt/local/share/asn1c/constr_CHOICE.h   -> constr_CHOICE.h
Copied /opt/local/share/asn1c/INTEGER.h -> INTEGER.h
Copied /opt/local/share/asn1c/NativeEnumerated.h    -> NativeEnumerated.h
Copied /opt/local/share/asn1c/INTEGER.c -> INTEGER.c
Copied /opt/local/share/asn1c/NativeEnumerated.c    -> NativeEnumerated.c
Copied /opt/local/share/asn1c/NativeInteger.h   -> NativeInteger.h
Copied /opt/local/share/asn1c/NativeInteger.c   -> NativeInteger.c
Copied /opt/local/share/asn1c/constr_CHOICE.c   -> constr_CHOICE.c
Copied /opt/local/share/asn1c/constr_SEQUENCE.h -> constr_SEQUENCE.h
Copied /opt/local/share/asn1c/constr_SEQUENCE.c -> constr_SEQUENCE.c
Copied /opt/local/share/asn1c/asn_application.h -> asn_application.h
Copied /opt/local/share/asn1c/asn_application.c -> asn_application.c
Copied /opt/local/share/asn1c/asn_ioc.h -> asn_ioc.h
Copied /opt/local/share/asn1c/asn_system.h  -> asn_system.h
Copied /opt/local/share/asn1c/asn_codecs.h  -> asn_codecs.h
Copied /opt/local/share/asn1c/asn_internal.h    -> asn_internal.h
Copied /opt/local/share/asn1c/asn_internal.c    -> asn_internal.c
Copied /opt/local/share/asn1c/asn_random_fill.h -> asn_random_fill.h
Copied /opt/local/share/asn1c/asn_random_fill.c -> asn_random_fill.c
Copied /opt/local/share/asn1c/asn_bit_data.h    -> asn_bit_data.h
Copied /opt/local/share/asn1c/asn_bit_data.c    -> asn_bit_data.c
Copied /opt/local/share/asn1c/OCTET_STRING.h    -> OCTET_STRING.h
Copied /opt/local/share/asn1c/OCTET_STRING.c    -> OCTET_STRING.c
Copied /opt/local/share/asn1c/BIT_STRING.h  -> BIT_STRING.h
Copied /opt/local/share/asn1c/BIT_STRING.c  -> BIT_STRING.c
Copied /opt/local/share/asn1c/asn_codecs_prim.c -> asn_codecs_prim.c
Copied /opt/local/share/asn1c/asn_codecs_prim.h -> asn_codecs_prim.h
Copied /opt/local/share/asn1c/ber_tlv_length.h  -> ber_tlv_length.h
Copied /opt/local/share/asn1c/ber_tlv_length.c  -> ber_tlv_length.c
Copied /opt/local/share/asn1c/ber_tlv_tag.h -> ber_tlv_tag.h
Copied /opt/local/share/asn1c/ber_tlv_tag.c -> ber_tlv_tag.c
Copied /opt/local/share/asn1c/ber_decoder.h -> ber_decoder.h
Copied /opt/local/share/asn1c/ber_decoder.c -> ber_decoder.c
Copied /opt/local/share/asn1c/der_encoder.h -> der_encoder.h
Copied /opt/local/share/asn1c/der_encoder.c -> der_encoder.c
Copied /opt/local/share/asn1c/constr_TYPE.h -> constr_TYPE.h
Copied /opt/local/share/asn1c/constr_TYPE.c -> constr_TYPE.c
Copied /opt/local/share/asn1c/constraints.h -> constraints.h
Copied /opt/local/share/asn1c/constraints.c -> constraints.c
Copied /opt/local/share/asn1c/xer_support.h -> xer_support.h
Copied /opt/local/share/asn1c/xer_support.c -> xer_support.c
Copied /opt/local/share/asn1c/xer_decoder.h -> xer_decoder.h
Copied /opt/local/share/asn1c/xer_decoder.c -> xer_decoder.c
Copied /opt/local/share/asn1c/xer_encoder.h -> xer_encoder.h
Copied /opt/local/share/asn1c/xer_encoder.c -> xer_encoder.c
Copied /opt/local/share/asn1c/per_support.h -> per_support.h
Copied /opt/local/share/asn1c/per_support.c -> per_support.c
Copied /opt/local/share/asn1c/per_decoder.h -> per_decoder.h
Copied /opt/local/share/asn1c/per_decoder.c -> per_decoder.c
Copied /opt/local/share/asn1c/per_encoder.h -> per_encoder.h
Copied /opt/local/share/asn1c/per_encoder.c -> per_encoder.c
Copied /opt/local/share/asn1c/per_opentype.h    -> per_opentype.h
Copied /opt/local/share/asn1c/per_opentype.c    -> per_opentype.c
Copied /opt/local/share/asn1c/converter-example.c   -> converter-example.c
Copied /opt/local/share/asn1c/oer_decoder.h -> oer_decoder.h
Copied /opt/local/share/asn1c/oer_decoder.c -> oer_decoder.c
Copied /opt/local/share/asn1c/oer_encoder.h -> oer_encoder.h
Copied /opt/local/share/asn1c/oer_encoder.c -> oer_encoder.c
Copied /opt/local/share/asn1c/oer_support.h -> oer_support.h
Copied /opt/local/share/asn1c/oer_support.c -> oer_support.c
Copied /opt/local/share/asn1c/OPEN_TYPE_oer.c   -> OPEN_TYPE_oer.c
Copied /opt/local/share/asn1c/INTEGER_oer.c -> INTEGER_oer.c
Copied /opt/local/share/asn1c/OCTET_STRING_oer.c    -> OCTET_STRING_oer.c
Copied /opt/local/share/asn1c/NativeInteger_oer.c   -> NativeInteger_oer.c
Copied /opt/local/share/asn1c/NativeEnumerated_oer.c    -> NativeEnumerated_oer.c
Copied /opt/local/share/asn1c/constr_SEQUENCE_oer.c -> constr_SEQUENCE_oer.c
Copied /opt/local/share/asn1c/constr_CHOICE_oer.c   -> constr_CHOICE_oer.c
Copied /opt/local/share/asn1c/constr_SET_OF_oer.c   -> constr_SET_OF_oer.c
Copied /opt/local/share/asn1c/constr_SET_OF.h   -> constr_SET_OF.h
Copied /opt/local/share/asn1c/asn_SET_OF.h  -> asn_SET_OF.h
Copied /opt/local/share/asn1c/asn_SET_OF.c  -> asn_SET_OF.c
Copied /opt/local/share/asn1c/BIT_STRING_oer.c  -> BIT_STRING_oer.c
Generated Makefile.am.targets
Generated Makefile.am.example
$ make -f Makefile.am.example 
clang -maes -mpclmul -mrdrnd -msse2 -mssse3 -msse4.2 -mtune=native -Os -Ofast  -DPDU=Test3 -I. -o Test3.o -c Test3.c
Test3.c:30:29: error: integer literal is too large to be represented in any integer type
        if((value >= 0 && value <= 9892233720368547758079)) {
                                   ^
Test3.c:61:29: error: integer literal is too large to be represented in any integer type
        if((value >= 0 && value <= 9892233720368547758071)) {
                                   ^
Test3.c:76:35: error: integer literal is too large to be represented in any integer type
        { APC_CONSTRAINED,       74, -1,  0,  9892233720368547758079 }  /* (0..98922...
                                              ^
Test3.c:84:35: error: integer literal is too large to be represented in any integer type
        { APC_CONSTRAINED,       74, -1,  0,  9892233720368547758071 }  /* (0..98922...
                                              ^
4 errors generated.
make: *** [Test3.o] Error 1
$ 
vlm commented 7 years ago

That 2^73, how would you like it to be handled?

mouse07410 commented 7 years ago

That 2^73, how would you like it to be handled?

Since it's larger than long long, I'd like it handled as ASN.1 INTEGER.

mouse07410 commented 7 years ago

@vlm may I ask what are your plans regarding this issue? Also, do you expect a similar problem with constraints of REAL type?