Skip to content

goto-instrument: function pointer typedefs #972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stahlbauer opened this issue May 26, 2017 · 1 comment
Closed

goto-instrument: function pointer typedefs #972

stahlbauer opened this issue May 26, 2017 · 1 comment

Comments

@stahlbauer
Copy link
Contributor

Function pointer types are not translated correctly by the current version of goto-instrument:

Input: typedef void (*__sighandler_t) (int);

Output: typedef void (*)(signed int) __sighandler_t;

GCC error:

error: expected identifier or ‘(’ before ‘)’ token
 typedef void (*)(signed int) __sighandler_t;

Full example for regression checks:

extern void* memset(void *, int, unsigned long);

typedef void (*__sighandler_t) (int);

typedef __sighandler_t sighandler_t;

typedef struct siginfo {                                                        
    int si_signo;                                                               
} siginfo_t;

struct sigaction {
	union {
	  __sighandler_t _sa_handler;
	  void (*_sa_sigaction)(int, struct siginfo *, void *);
	} _u;
};

#define sa_sigaction	_u._sa_sigaction
#define sa_handler	_u._sa_handler

static void askpass_timeout(signed int ignore) {
  ;
}

int main() {
  struct sigaction sa, oldsa;
  memset(&sa, 0, sizeof(sa));
  sa.sa_handler = askpass_timeout;    
  return 0;
}

@tautschnig: FYI

@tautschnig
Copy link
Collaborator

Fix included in #858 (my previous attempt at constructing the typedef string could safely be called stupid).

tautschnig added a commit to tautschnig/cbmc that referenced this issue Jun 8, 2017
Follow-up to 99067de, which made expr2c prefer typedef names over
original type expressions.

Thanks Andreas Stahlbauer for providing the regression tests and help in
debugging.

Fixes: diffblue#882
Fixes: diffblue#964
Fixes: diffblue#972
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants