Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

101
Views
¿Tiene GCC funciones para detectar errores de uso después de la liberación?

Aquí está mi fragmento de código:

 #include <stdlib.h> #include <stdio.h> typedef struct node { char key; // value struct node *next; // pointer to the next element } Node; int main(void) { Node *n = malloc(sizeof(Node)); n->key = 'K'; n->next = NULL; free(n); printf("%c\n", n->key); }

Cuando se compila y ejecuta el fragmento anterior...

 ganningxu@Gannings-Computer:~/test$ gcc test_faults.c -o test_faults; ./test_faults K ganningxu@Gannings-Computer:~/test$ clang test_faults.c -o test_faults; ./test_faults K

No hay advertencias ni errores del compilador cuando se accede a la memoria liberada. ¿Hay alguna forma de obligar al compilador a mostrar tales errores?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Al compilar con GCC, puede usar -fsanitize=address para que "las instrucciones de acceso a la memoria estén instrumentadas para detectar errores fuera de los límites y uso después de la liberación". Por supuesto, esto afectará el rendimiento del programa y también puede cambiar el comportamiento del programa si hay errores.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!