This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/22597] [3.4/4.0 Regression] pure attribute produces incorrect results


------- Additional Comments From reichelt at gcc dot gnu dot org  2005-07-25 16:02 -------
I don't think that Andrew's example is valid, since a pure function
modifies global data. Btw, shouldn't the compiler complain about that?

Here's an example that is valid IMHO:

==================================================
extern "C" void abort();

struct A
{
    int i;

    A()           : i(1) {}
    A(const A& a) : i(1) {}
};

A __attribute__((pure)) foo() { return A(); }

int main()
{
    if (foo().i != 1)
        abort();
    return 0;
}
==================================================

The abort is triggered on the 3.4 branch and the 4.0 branch.
GCC 3.3.6 and mainline work fine.

The same happens, if one uses __attribute__((const)).


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |reichelt at gcc dot gnu dot
                   |                            |org
           Keywords|                            |monitored
      Known to fail|4.0.1                       |3.4.0 4.0.1
      Known to work|3.4.0 4.1.0                 |3.3.6 4.1.0
            Summary|[4.0 Regression] pure       |[3.4/4.0 Regression] pure
                   |attribute produces incorrect|attribute produces incorrect
                   |results                     |results


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22597


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]