[gcc accept invalid ?] copy volatile struct

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



G++ 4.7.2 and 4.9-trunk compiles the following code without errors

$ cat x.ii
struct A
{
    volatile struct {} f;
};

struct B
{
    A s;
};

B b;
void foo()
{
    A a;
    a = b.s;
}

But clang++-trunk not.

I ask in cfe-users maillist and receive answer from David Blaikie:
"Seems like a case of accepts-invalid in other compilers"
(http://lists.cs.uiuc.edu/pipermail/cfe-users/2013-April/000085.html)

So my question is: what is the right ? accept or reject a such code?

Thanks,
Dmitry

$ clang++ -fsyntax-only x.ii
x.ii:1:8: error: member function 'operator=' not viable: 'this'
argument has type
      'volatile struct <anonymous struct at x.ii:3:14>', but function
is not marked
      volatile
struct A
       ^
x.ii:3:14: note: 'operator=' declared here
    volatile struct {} f;
             ^
x.ii:15:7: note: implicit default copy assignment operator for 'A'
first required here
    a = b.s;
...
$ clang++ --version
clang version 3.3 (trunk 180598)
...

$ g++ --version
g++ (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8)
...
$ g++ -Wall -Wextra -fsyntax-only x.ii


$ g++ --version
g++ (GCC) 4.9.0 20130420 (experimental) [trunk revision 198109]
...
$ g++ -Wall -Wextra -fsyntax-only x.ii




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux