]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR ada/89349 (segfault when building GCC 7 & 8 branch with GCC master)
authorEric Botcazou <ebotcazou@adacore.com>
Sat, 23 Feb 2019 10:04:41 +0000 (10:04 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sat, 23 Feb 2019 10:04:41 +0000 (10:04 +0000)
PR ada/89349
Backport from mainline
2018-05-25  Arnaud Charlet  <charlet@adacore.com>

* osint.ads (Unknown_Attributes): No longer pretend this is a constant.
(No_File_Info_Cache): Initialize separately.
* osint.adb (No_File_Info_Cache): Update initializer.

From-SVN: r269154

gcc/ada/ChangeLog
gcc/ada/osint.adb
gcc/ada/osint.ads

index 11a9ff15fe16191781101b3653709f63d0f2de1d..ee33d9fb21e699d77d1f969286c054a56b3c6d7b 100644 (file)
@@ -1,3 +1,13 @@
+2019-02-23  Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR ada/89349
+       Backport from mainline
+       2018-05-25  Arnaud Charlet  <charlet@adacore.com>
+
+       * osint.ads (Unknown_Attributes): No longer pretend this is a constant.
+       (No_File_Info_Cache): Initialize separately.
+       * osint.adb (No_File_Info_Cache): Update initializer.
+
 2019-02-08  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/trans.c (Loop_Statement_to_gnu): Replace tests on
index 8c6c22b9d1452e87ef0bbfd4bfa9d96119a7f1b5..1ede04ff564657da70d79bee8ffbd714df69751d 100644 (file)
@@ -250,8 +250,7 @@ package body Osint is
       Attr : aliased File_Attributes;
    end record;
 
-   No_File_Info_Cache : constant File_Info_Cache :=
-                          (No_File, Unknown_Attributes);
+   No_File_Info_Cache : constant File_Info_Cache := (No_File, (others => 0));
 
    package File_Name_Hash_Table is new GNAT.HTable.Simple_HTable (
      Header_Num => File_Hash_Num,
index a96e83ea8e78fecaf2ffe938fa5899f7a72cdb6e..893ff7b073893d8865b2e3d348b2dc4f461dfb04 100644 (file)
@@ -273,10 +273,26 @@ package Osint is
    --  from the disk and then cached in the File_Attributes parameter (possibly
    --  along with other values).
 
-   type File_Attributes is private;
-   Unknown_Attributes : constant File_Attributes;
+   File_Attributes_Size : constant Natural := 32;
+   --  This should be big enough to fit a "struct file_attributes" on any
+   --  system. It doesn't cause any malfunction if it is too big (which avoids
+   --  the need for either mapping the struct exactly or importing the sizeof
+   --  from C, which would result in dynamic code). However, it does waste
+   --  space (e.g. when a component of this type appears in a record, if it is
+   --  unnecessarily large). Note: for runtime units, use System.OS_Constants.
+   --  SIZEOF_struct_file_attributes instead, which has the exact value.
+
+   type File_Attributes is
+     array (1 .. File_Attributes_Size)
+       of System.Storage_Elements.Storage_Element;
+   for File_Attributes'Alignment use Standard'Maximum_Alignment;
+
+   Unknown_Attributes : File_Attributes;
    --  A cache for various attributes for a file (length, accessibility,...)
-   --  This must be initialized to Unknown_Attributes prior to the first call.
+   --  Will be initialized properly at elaboration (for efficiency later on,
+   --  avoid function calls every time we want to reset the attributes) prior
+   --  to the first usage. We cannot make it constant since the compiler may
+   --  put it in a read-only section.
 
    function Is_Directory
      (Name : C_File_Name;
@@ -769,22 +785,4 @@ private
    --  detected, the file being written is deleted, and a fatal error is
    --  signalled.
 
-   File_Attributes_Size : constant Natural := 32;
-   --  This should be big enough to fit a "struct file_attributes" on any
-   --  system. It doesn't cause any malfunction if it is too big (which avoids
-   --  the need for either mapping the struct exactly or importing the sizeof
-   --  from C, which would result in dynamic code). However, it does waste
-   --  space (e.g. when a component of this type appears in a record, if it is
-   --  unnecessarily large). Note: for runtime units, use System.OS_Constants.
-   --  SIZEOF_struct_file_attributes instead, which has the exact value.
-
-   type File_Attributes is
-     array (1 .. File_Attributes_Size)
-       of System.Storage_Elements.Storage_Element;
-   for File_Attributes'Alignment use Standard'Maximum_Alignment;
-
-   Unknown_Attributes : constant File_Attributes := (others => 0);
-   --  Will be initialized properly at elaboration (for efficiency later on,
-   --  avoid function calls every time we want to reset the attributes).
-
 end Osint;