Re: Bus error when writing in a typed file

Baudouin Le Charlier <[email protected]>
Newsgroups gmane.comp.compilers.gpc
Message-ID <[email protected]>
Le 18 nov. 2012 à 16:18, Prof A Olowofoyeku (The African Chief) a écrit :

> On 18 Nov 2012 at 10:16, Baudouin Le Charlier wrote:
> 
>>  Here is a very simple example where the bus error occurs :
>> 
>> I executed the following commands :
>> 
>> Soeur-Sourire:Cours17 blc$ gp busError.pas 
>> Soeur-Sourire:Cours17 blc$ ./busError 
>> Bus error
>> Soeur-Sourire:Cours17 blc$ 
>> 
>> After executing the program, the file toto.pers exists and is empty
>> (Zero bytes).
>> 
> 
> Apart from the fact that nothing in the record is initialialised, this 
> is the offending statement:
>        case sexe : boolean of
>          true : (nomDeJeuneFille : string80) ;
>          false : (matricule : string10) 
> 
> What I am about to say may simply expose my ignorance - but I will say 
> it anyway. I am no compiler writer, and I don't use variant records 
> myself - but, from where I am standing, I am at a loss to know what the 
> size of the "personne" record is. "nomDeJeuneFille" and "matricule" are 
> supposed to occupy the same location, but they are not the same size. 
> So what data size is the "file of personne" expecting? Data that will 
> vary in size depending on a value that is not known at compile time? Is 
> this allowed?

  Dear Chief,

  It's a great joy to have a chance to discuss with you thanks to a "bus error". To my understanding the size of the "personne" record is completely implementation dependent. But this should not cause an error when writing the record into a file. Of course a "file of personne" created with gnu pascal is not supposed to be readable with any other pascal implementation.
  The reason why I did not bother to initialize the record is just to shorten the original program to simplify debugging.

Baudouin Le Charlier



> 
> Best regards, The Chief
> --------
> Prof. Abimbola A. Olowofoyeku (The African Chief) 
> web:  http://www.greatchief.plus.com/
> 


_______________________________________________
Gpc mailing list
[email protected]
https://www.g-n-u.de/mailman/listinfo/gpc
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.