Re: tcc - first impression. Was: Baby X is bor nagain

Liste des GroupesRevenir à cl c  
Sujet : Re: tcc - first impression. Was: Baby X is bor nagain
De : ben (at) *nospam* bsb.me.uk (Ben Bacarisse)
Groupes : comp.lang.c
Date : 02. Jul 2024, 17:12:47
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <87msmzkc1s.fsf@bsb.me.uk>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
User-Agent : Gnus/5.13 (Gnus v5.13)
Michael S <already5chosen@yahoo.com> writes:

On Tue, 02 Jul 2024 16:32:23 +0100
Ben Bacarisse <ben@bsb.me.uk> wrote:
>
Michael S <already5chosen@yahoo.com> writes:
 
On Mon, 1 Jul 2024 20:09:24 +0300
Michael S <already5chosen@yahoo.com> wrote:
>
As far as I am concerned, the most intriguing feature of tcc is
"Memory and Bound checks". Unfortunately, I was not able to make it
work. It keeps telling me "segmentation error" at first attempt to
dereference argv. Is this feature Linux-only or 32-bit only or some
other type of "only" ? 
 
The documentation says it should work on x86_64 in Windows.
 
Can you post the code so we can compare.  With this little program
 
  #include <stdio.h>
  
  void f(int *a, int n)
  {
       printf("a[%d] == %d\n", n, a[n]);
  }
  
  int main(int argc, char **argv)
  {
       for (int i = 0; i <= argc; i++)
            if (argv[i])
                 printf("argv[%d] == %s\n", i, argv[i]);
            else printf("argv[%d] is a null pointer\n", i);
       int a[3];
       f(a, 3);
  }
 
I get this output:
 
$ ./a.out 1
argv[0] == ./a.out
argv[1] == 1
argv[2] is a null pointer
004021b9 : at ???: BCHECK: 0x7ffca6719404 is outside of the region
t.c:5: by f
t.c:15: by main
t.c:5: at f: RUNTIME ERROR: invalid memory access
t.c:15: by main   
 
>
I got plain "Segmentation fault".
>
I it gets me "Segmentation fault" on something as simple as:
>
#include <stdio.h>
int main(int argc, char **argv)
{
  printf("%p\n", argv[0]);
  return 0;
}

Ah.  That looks like a plain "not working" then.  (Presumably you get a
reasonable-looking pointer without the -b option).  What version of tcc?

--
Ben.

Date Sujet#  Auteur
27 Jun 24 o Re: Baby X is bor nagain36Tim Rentsch

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal