Menu

CompilerIssues

Simon Wright

There are some source code constructs that, while perfectly legal and working under desktop compilations, cause errors with this RTS. This is probably caused by misunderstanding of the exact interface between the compiler and the RTS, which is complex (to put it mildly).

Compiler mistakes restriction violation [tickets:#11]

A package containing an instantiation of Ada.Containers.Bounded_Vectors couldn’t be linked because the compiler (GCC 4.9.1 and GNAT GPL 2014) had mistakenly decided that it violated the restriction No_Implicit_Heap_Allocations (which is part of the Ravenscar profile).

GCC 5.0.0 doesn’t have this error.

A workround (which allowed the package which revealed the problem to be built) was to explicitly state the restriction in the body:

pragma Restrictions (No_Implicit_Heap_Allocations);

with Ada.Containers.Bounded_Vectors;

package body Containing is

   subtype Index is Natural range 0 .. 19;
   subtype Line is String (1 .. 20);

   package Line_Vectors
     is new Ada.Containers.Bounded_Vectors (Index_Type   => Index,
                                            Element_Type => Line);

Attach_Handler must be in pragma form

In this code

protected Button
with
  Interrupt_Priority => System.Interrupt_Priority'First
is
   entry Wait_For_Trigger;
private
   Triggered : Boolean := False;
   procedure Handler;
   pragma Attach_Handler (Handler, Ada.Interrupts.Names.EXTI0_IRQ);
end Button;

you would have liked to attach the handler using the aspect syntax,

   procedure Handler
   with
     Attach_Handler => Ada.Interrupts.Names.EXTI0_IRQ;

but this doesn’t work in GCC 4.9.1 (it’s OK in GNAT GPL 2014 & GCC 5.0.0).


Related

Tickets: #11
Wiki: Home

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.