GCC Version: 3.4.2 OS: Solaris 8 GCC build: ../gcc-3.4.2/configure --enable-languages=c,c++,ada --disable- shared --srcdir=/tools/gcc-3.4.2/gcc-3.4.2 The following code will cause a "use_error" to be raised => with Direct_IO, Text_IO; procedure testit is type Item is record Buffer : String (1..10) := (Others => ' '); Len : Integer := 0; end record; package Dir_IO is new Direct_IO (item); FD : Dir_IO.File_Type; Itm : Item; begin -- Create a file using DIRECT_IO Dir_IO.Create (FD, Dir_IO.Out_File, "testfile.txt") -- Put some data in file for Counter in 1..10 loop Dir_IO.Write (FD, Itm); end loop; -- Close file Dir_IO.Close (FD); -- Now reopen with shared file access Dir_IO.Open (FD, Dir_IO.In_File, "testfile.txt", "shared=yes"); -- Open with shared file access Dir_IO.Reset (FD); -- This will raise an error due to shared file access! Dir_IO.Close (FD); Text_IO.Put_Line ("Finished program."); exception when Dir_IO.Use_Error => Text_IO.Put_Line ("Use Error was raised!"); when Others => Text_IO.Put_Line ("Error was raised!"); end testit; When reseting a file that does not change mode, the Reset should rewind the file without any problem. The code is incorrect. The GCC ada file "s-fileio.adb" Reset procedure calls another Reset procedure that takes a mode parameter. This procedure then checks for a file in shared access mode, and then raises an error. This is not correct. If the Mode of the file did not change, then the file should be reset and no error should occur. The Reset procedure in "s-fileio.adb" should be rewitten as follows => procedure Reset (File : in out AFCD_Ptr; Mode : in File_Mode) is Fopstr : aliased Fopen_String; begin Check_File_Open (File); if File.Name'Length <= 1 or else File.Is_System_File or else (not File.Is_Regular_file_ then raise Use_Error; elsif Mode = File.Mode and then Mode <= Inout_file then rewind (File.Stream); else -- Check to see if the mode is Shared. If it is, then raise a -- Use_Error becuase this mode is not allowed. if File.Shared_Status = Yes then raise Use_Error; end if; Fopen_Mode (Mode, File.Is_Text_File, False, File.Access_Method, Fopstr); File.Stream := freopen (File.Name.all'Address, Fopstr'Address, File.Stream); if File.Stream = NULL_Stream then Close (File); raise Use_Error; else File.Mode := Model Append_Set (File); end if; end if; end Reset;
Nothing critical about this bug, so changing severity/priority. Arno
(In reply to comment #1) > Nothing critical about this bug, so changing severity/priority. > Arno (In reply to comment #1) We have ported over 1200 files from Verdix to the GCC compiler and have a few problems with the GNAT version of GCC. While you may not consider this a "critical bug", our system will crash and is unusable without this fix. The verdix compiler used "shared" file access by default, and the reset worked with no problems. Under GCC, this is killing us. While I do not mind making it a "normal" bug fix, PLEASE get this change into the next GCC release.
This is a place where you can report bugs to volunteers, so it is inapropriate to make this kind of request nor expect guarantees as to when bugs should be fixed. If you need guarantees on fixes, I'd suggest getting support for GNAT with a company that provides the kind of support you need. Arno
Subject: Bug 22255 Author: sam Date: Wed Feb 27 12:12:14 2008 New Revision: 132708 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132708 Log: gcc/ada/ PR ada/22255 * s-fileio.adb (Reset): Do not raise Use_Error if mode isn't changed. gcc/testsuite/ PR ada/22255 * gnat.dg/test_direct_io.adb: New file. Added: trunk/gcc/testsuite/gnat.dg/test_direct_io.adb Modified: trunk/gcc/ada/ChangeLog trunk/gcc/ada/s-fileio.adb trunk/gcc/testsuite/ChangeLog
Fixed in SVN trunk