#40683 [NEW]: zend_operators.h generates discard qualifier compiler warning

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #40683 [NEW]: zend_operators.h generates discard qualifier compiler warning

    From: lstefani at fortresstech dot com
    Operating system: linux 2.6.12-1.1381_FC3smp
    PHP version: 5.2.1
    PHP Bug Type: Compile Warning
    Bug description: zend_operators.h generates discard qualifier compiler warning

    Description:
    ------------
    Zend/zend_operators.h: In function `void* zend_memrchr(const void*, int,
    unsigned int)':
    Zend/zend_operators.h:250: warning: cast from `const void*' to `unsigned
    char*' discards qualifiers from pointer target type
    Zend/zend_operators.h:250: warning: cast from `const void*' to `unsigned
    char*' discards qualifiers from pointer target type


    In code snippet, line 250 refers to the two recasts of argument s.

    Reproduce code:
    ---------------
    static inline void *zend_memrchr(const void *s, int c, size_t n)
    {
    register unsigned char *e;

    if (n <= 0) {
    return NULL;
    }

    for (e = (unsigned char *)s + n - 1; e >= (unsigned char *)s; e--) {
    if (*e == (unsigned char)c) {
    return (void *)e;
    }
    }

    return NULL;
    }


    Expected result:
    ----------------
    No compiler warnings.


    --
    Edit bug report at [url]http://bugs.php.net/?id=40683&edit=1[/url]
    --
    Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40683&r=trysnapshot44[/url]
    Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40683&r=trysnapshot52[/url]
    Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40683&r=trysnapshot60[/url]
    Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40683&r=fixedcvs[/url]
    Fixed in release: [url]http://bugs.php.net/fix.php?id=40683&r=alreadyfixed[/url]
    Need backtrace: [url]http://bugs.php.net/fix.php?id=40683&r=needtrace[/url]
    Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40683&r=needscript[/url]
    Try newer version: [url]http://bugs.php.net/fix.php?id=40683&r=oldversion[/url]
    Not developer issue: [url]http://bugs.php.net/fix.php?id=40683&r=support[/url]
    Expected behavior: [url]http://bugs.php.net/fix.php?id=40683&r=notwrong[/url]
    Not enough info: [url]http://bugs.php.net/fix.php?id=40683&r=notenoughinfo[/url]
    Submitted twice: [url]http://bugs.php.net/fix.php?id=40683&r=submittedtwice[/url]
    register_globals: [url]http://bugs.php.net/fix.php?id=40683&r=globals[/url]
    PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40683&r=php3[/url]
    Daylight Savings: [url]http://bugs.php.net/fix.php?id=40683&r=dst[/url]
    IIS Stability: [url]http://bugs.php.net/fix.php?id=40683&r=isapi[/url]
    Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40683&r=gnused[/url]
    Floating point limitations: [url]http://bugs.php.net/fix.php?id=40683&r=float[/url]
    No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40683&r=nozend[/url]
    MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40683&r=mysqlcfg[/url]
    lstefani at fortresstech dot com Guest

  2. Similar Questions and Discussions

    1. #36812 [Asn->Csd]: bind NULL variables generates warning
      ID: 36812 Updated by: iliaa@php.net Reported By: ce at netage dot bg -Status: Assigned +Status: ...
    2. #36812 [Asn]: bind NULL variables generates warning
      ID: 36812 Updated by: dave@php.net Reported By: ce at netage dot bg Status: Assigned Bug Type: ...
    3. Force Compiler Error/Warning Within Custom Control
      I assume there's a way to do this since I've seen third-party components act the same way. How do I force the compiler to throw an error or...
    4. #36812 [Opn->Asn]: bind NULL variables generates warning
      ID: 36812 Updated by: tony2001@php.net Reported By: ce at netage dot bg -Status: Open +Status: ...
    5. [PHP-DEV] [PATCH] Fix for 64-bit arch errors in zend_operators.c
      --------------080104000508040900060706 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hello group, ...
  3. #2

    Default #40683 [Opn->Fbk]: zend_operators.h generates discard qualifier compiler warning

    ID: 40683
    Updated by: [email]tony2001@php.net[/email]
    Reported By: lstefani at fortresstech dot com
    -Status: Open
    +Status: Feedback
    Bug Type: Compile Warning
    Operating System: linux 2.6.12-1.1381_FC3smp
    PHP Version: 5.2.1
    New Comment:

    What compiler do you use?


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-03-01 19:44:25] lstefani at fortresstech dot com

    Description:
    ------------
    Zend/zend_operators.h: In function `void* zend_memrchr(const void*,
    int, unsigned int)':
    Zend/zend_operators.h:250: warning: cast from `const void*' to
    `unsigned char*' discards qualifiers from pointer target type
    Zend/zend_operators.h:250: warning: cast from `const void*' to
    `unsigned char*' discards qualifiers from pointer target type


    In code snippet, line 250 refers to the two recasts of argument s.

    Reproduce code:
    ---------------
    static inline void *zend_memrchr(const void *s, int c, size_t n)
    {
    register unsigned char *e;

    if (n <= 0) {
    return NULL;
    }

    for (e = (unsigned char *)s + n - 1; e >= (unsigned char *)s; e--) {
    if (*e == (unsigned char)c) {
    return (void *)e;
    }
    }

    return NULL;
    }


    Expected result:
    ----------------
    No compiler warnings.



    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40683&edit=1[/url]
    tony2001@php.net Guest

  4. #3

    Default #40683 [NoF->Opn]: zend_operators.h generates discard qualifier compiler warning

    ID: 40683
    User updated by: lstefani at fortresstech dot com
    Reported By: lstefani at fortresstech dot com
    -Status: No Feedback
    +Status: Open
    Bug Type: Compile Warning
    Operating System: linux 2.6.12-1.1381_FC3smp
    PHP Version: 5.2.1
    New Comment:

    Sorry for the late response. Your email hit my company spam filter for
    some reason. Just found it while going through the bulk mail folder.

    To answer your question, I'm using the MIPS cross-compiler (GCC 3.3.2
    and GLIBC 2.3.2) on Linux x86. I know that's not the latest GCC
    compiler by a long shot, but just from reviewing the code, it does
    appear that the const declaration is being discarded by recasting the
    parameter as an unsigned char.


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-03-09 01:00:01] php-bugs at lists dot php dot net

    No feedback was provided for this bug for over a week, so it is
    being suspended automatically. If you are able to provide the
    information that was originally requested, please do so and change
    the status of the bug back to "Open".

    ------------------------------------------------------------------------

    [2007-03-01 19:59:07] [email]tony2001@php.net[/email]

    What compiler do you use?

    ------------------------------------------------------------------------

    [2007-03-01 19:44:25] lstefani at fortresstech dot com

    Description:
    ------------
    Zend/zend_operators.h: In function `void* zend_memrchr(const void*,
    int, unsigned int)':
    Zend/zend_operators.h:250: warning: cast from `const void*' to
    `unsigned char*' discards qualifiers from pointer target type
    Zend/zend_operators.h:250: warning: cast from `const void*' to
    `unsigned char*' discards qualifiers from pointer target type


    In code snippet, line 250 refers to the two recasts of argument s.

    Reproduce code:
    ---------------
    static inline void *zend_memrchr(const void *s, int c, size_t n)
    {
    register unsigned char *e;

    if (n <= 0) {
    return NULL;
    }

    for (e = (unsigned char *)s + n - 1; e >= (unsigned char *)s; e--) {
    if (*e == (unsigned char)c) {
    return (void *)e;
    }
    }

    return NULL;
    }


    Expected result:
    ----------------
    No compiler warnings.



    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40683&edit=1[/url]
    lstefani at fortresstech dot com Guest

  5. #4

    Default #40683 [Opn->WFx]: zend_operators.h generates discard qualifier compiler warning

    ID: 40683
    Updated by: [email]tony2001@php.net[/email]
    Reported By: lstefani at fortresstech dot com
    -Status: Open
    +Status: Wont fix
    Bug Type: Compile Warning
    Operating System: linux 2.6.12-1.1381_FC3smp
    PHP Version: 5.2.1
    New Comment:

    You can safely ignore it.
    And no, I can't reproduce this warning with GCC4 & GCC3.4.6 or any
    other compiler.


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-03-12 00:08:58] lstefani at fortresstech dot com

    Sorry for the late response. Your email hit my company spam filter for
    some reason. Just found it while going through the bulk mail folder.

    To answer your question, I'm using the MIPS cross-compiler (GCC 3.3.2
    and GLIBC 2.3.2) on Linux x86. I know that's not the latest GCC
    compiler by a long shot, but just from reviewing the code, it does
    appear that the const declaration is being discarded by recasting the
    parameter as an unsigned char.

    ------------------------------------------------------------------------

    [2007-03-09 01:00:01] php-bugs at lists dot php dot net

    No feedback was provided for this bug for over a week, so it is
    being suspended automatically. If you are able to provide the
    information that was originally requested, please do so and change
    the status of the bug back to "Open".

    ------------------------------------------------------------------------

    [2007-03-01 19:59:07] [email]tony2001@php.net[/email]

    What compiler do you use?

    ------------------------------------------------------------------------

    [2007-03-01 19:44:25] lstefani at fortresstech dot com

    Description:
    ------------
    Zend/zend_operators.h: In function `void* zend_memrchr(const void*,
    int, unsigned int)':
    Zend/zend_operators.h:250: warning: cast from `const void*' to
    `unsigned char*' discards qualifiers from pointer target type
    Zend/zend_operators.h:250: warning: cast from `const void*' to
    `unsigned char*' discards qualifiers from pointer target type


    In code snippet, line 250 refers to the two recasts of argument s.

    Reproduce code:
    ---------------
    static inline void *zend_memrchr(const void *s, int c, size_t n)
    {
    register unsigned char *e;

    if (n <= 0) {
    return NULL;
    }

    for (e = (unsigned char *)s + n - 1; e >= (unsigned char *)s; e--) {
    if (*e == (unsigned char)c) {
    return (void *)e;
    }
    }

    return NULL;
    }


    Expected result:
    ----------------
    No compiler warnings.



    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40683&edit=1[/url]
    tony2001@php.net Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139