Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mycoboco
Copy link

This commit lets lcc correctly diagnose the following code:

typedef void (*fp_t)(void);

fp_t func(fp_t param)
{
    return (void *)0;          /* line A */
}

int main(void)
{
    fp_t t = (void *)0;       /* line B */
    t = (void *)0;            /* line C */
    return func((void *)0)    /* line D */
               == (void *)0;
}

According to the Standard, the commented lines above should not be considered non-portable while lcc says:

5: warning: conversion from `pointer to void' to `pointer to void function(void)' is compiler dependent
10: warning: conversion from `pointer to void' to `pointer to void function(void)' is compiler dependent
11: warning: conversion from `pointer to void' to `pointer to void function(void)' is compiler dependent
12: warning: conversion from `pointer to void' to `pointer to void function(void)' is compiler dependent

EDIT: an example regarding a conditional expression and NPC has been removed because it was wrong; constant expressions can be or have conditional expressions. No problem with them in lcc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant