Quantcast
Viewing all articles
Browse latest Browse all 1616

Incorrect resolution of class in anonymous namespace

Hii

We came across an issue in our Intel (2016) compiler build where it appears separate, but identically named, classes in anonymous namespaces are not being resolved correctly. We've managed to create small example that illustrates the problem, and wondered if somebody could please investigate.

In the attached source you can see two definitions of class Local within anaonymous namespaces in separate translation units (case1.cpp and case2.cpp). What appears to be happening is that the two objects are not being resolved correctly, and in this case a segmentation fault ensues when the object is accessed.

Compare the output from g++ (4.9):

We are in case1
instance(): N12_GLOBAL__N_15LocalE sized as 8
getThreadLocalInstance(): current N12_GLOBAL__N_15LocalE sized as 8 @ 0
instance(): N12_GLOBAL__N_15LocalE sized as 8
getThreadLocalInstance(): new N12_GLOBAL__N_15LocalE sized as 8 @ 0x1cad7010

We are in case2
instance(): N12_GLOBAL__N_15LocalE sized as 8
getThreadLocalInstance(): current N12_GLOBAL__N_15LocalE sized as 8 @ 0
instance(): N12_GLOBAL__N_15LocalE sized as 8
getThreadLocalInstance(): new N12_GLOBAL__N_15LocalE sized as 8 @ 0x1cad7080

We are in case1
instance(): N12_GLOBAL__N_15LocalE sized as 8
getThreadLocalInstance(): current N12_GLOBAL__N_15LocalE sized as 8 @ 0x1cad7010
myA=XXX

We are in case2
instance(): N12_GLOBAL__N_15LocalE sized as 8
getThreadLocalInstance(): current N12_GLOBAL__N_15LocalE sized as 8 @ 0x1cad7080
myA=1234567

and that from icpc:

We are in case1
instance(): N12_GLOBAL__N_15LocalE sized as 8
getThreadLocalInstance(): current N12_GLOBAL__N_15LocalE sized as 8 @ 0
instance(): N12_GLOBAL__N_15LocalE sized as 8
getThreadLocalInstance(): new N12_GLOBAL__N_15LocalE sized as 8 @ 0x6d59010

We are in case2
instance(): N12_GLOBAL__N_15LocalE sized as 8
getThreadLocalInstance(): current N12_GLOBAL__N_15LocalE sized as 8 @ 0x6d59010

We are in case1
instance(): N12_GLOBAL__N_15LocalE sized as 8
getThreadLocalInstance(): current N12_GLOBAL__N_15LocalE sized as 8 @ 0x6d59010
Segmentation fault

In the latter you will see that both the case1 and case2 objects are at the same address, and then we get a segfault, according to gdb, on attempting to print the member variable (at case1.cpp:26)

To build this example just run "make CXX=icpc" and/or "make CXX=g++"

Thanks,
Andrew

PS Just noticed the issue has already been raised here: https://software.intel.com/en-us/forums/intel-c-compiler/topic/597089

 

 

AdjuntoTamaño
DescargarImage may be NSFW.
Clik here to view.
application/x-gtar
intel_issue.tgz
906 bytes

Viewing all articles
Browse latest Browse all 1616

Trending Articles