asn1c: Generating code using ‘Automatic Tags’ and negative value as default value creates invalid function names

The following post is for the (repository:

When compiling the following ASN.1 data structure


    Coordinates ::= SEQUENCE
        -- latitude from -90 till 90 degrees --
        latitude INTEGER(-9000000..9000000) DEFAULT -8000000,
        -- longitude from -180 till 179.99999 degrees, worst precision 1.1132m at equator --
        longitude INTEGER(-18000000..17999999) DEFAULT -12000000


the use of both the AUTOMATIC TAGS option and the use of a negative value -8000000 in the position of the default value causes asn1c to create invalid function names in the Coordinates object.

For example, the above ASN.1 syntax will produce the following invalid function name int asn_DFL_2_set_-800000(int set_value, void **sptr).

Compilation command for asn1c

From folder asn1c_gps/asn1 we used the following command:

/home/developer/asn1c/asn1c/asn1c -pdu=auto -S /home/developer/asn1c/skeletons/ -fcompound-names -gen-PER ../geography.asn1

Version of asn1c

'ASN.1 Compiler, v0.9.28'


Full example code demonstrating the bug can be found here ( asn1c_gps - Full example - Demonstrating Bug (83 downloads) ).

If you want to use the code and see that all other operations are fine, replace _- with _minus_ in the file Coordinates.c and the code will become valid and usable.

After you perform the above change, you can use the code in main.cpp to see the our cycle of execution that encodes and decodes an object.

This post is also available in: Greek

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.