group and dataset same name


I'm not sure if the following is the intended behavior or the issue, but I
wanted to see if there is any solution available to it.
If the group name and the dataset name are same, it generates following
error. Following is the excerpt of the code:

Group grp = file->createGroup("ABC");
Group grp1 = grp.createGroup("XYZ");

DataSet* dataset;
dataset = new DataSet(grp.createDataSet("XYZ", INT, space, cparms));

On execution, it shows following error
H5L.c line 1668 in H5L_link_cb() : name already exists
major: Symbol table
minor: Object already exists

In our data feed, we receive structs and elements, structs becomes group
and elements becomes datasets. So the groups are created upfront and then
there is a complex massaging of data as we receive; in which case normally
dataset "XYZ" would be created under group "XYZ", but under special
circumstances we have to dump the group "XYZ" and create the dataset under
group "ABC".

I also tried closing the group (grp1.close()) before creating the dataset,
but still get the same error. Is there a possible solution to this issue?

Best Regards,

Anal Patel
Raytheon, Inc.