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; -- Summary: Reset on shared file causes Use_Error. Product: gcc Version: 3.4.2 Status: UNCONFIRMED Severity: critical Priority: P1 Component: ada AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: brianstensrude at hotmail dot com CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22255