Skip to content

Fast DDS-Gen silently accepts invalid IDL with duplicate enum literals and drops the duplicate #591

Description

@wuyuqa

Is there an already existing issue for this?

  • I have searched the existing issues

Expected behavior

Fast DDS-Gen should reject this IDL and return a non-zero exit status, because duplicate enum literals are invalid IDL declarations.

CycloneDDS rejects the same input:

Declaration 'ZERO' collides with an earlier declaration of 'ZERO'

OpenDDS rejects the same input:

illegal redefinition ::test::ZERO, ::test::DuplicateEnumState, ::test::ZERO

Current behavior

Fast DDS-Gen exits with status 0 and generates type support files:

Processing the file duplicate_enum_literal.idl...
Generating Type definition files...
Generating Type Support files...
Generating TypeObjectSupport files...
Adding project: duplicate_enum_literal.idl

The generated C++ enum silently contains only three enumerators:

enum class DuplicateEnumState : int32_t
{
    ZERO,
    ONE,
    MAX
};

The generated TypeObject support also builds only three enumerated literals, with ordinals 0, 1, and 2. The second ZERO from the input IDL is dropped without any diagnostic.

Steps to reproduce

Minimal reproducer

duplicate_enum_literal.idl:

module test {
  enum DuplicateEnumState { ZERO, ONE, MAX, ZERO };

  struct DuplicateEnumSample {
    long id;
    DuplicateEnumState state;
  };
};

Steps to reproduce

Run Fast DDS-Gen:

fastddsgen -d /tmp/fastddsgen_duplicate_enum_out -replace duplicate_enum_literal.idl
echo "$?"
grep -R -n "enum class DuplicateEnumState\\|ZERO\\|ONE\\|MAX" /tmp/fastddsgen_duplicate_enum_out

### Fast DDS version/commit

## Affected versions tested

- Fast DDS-Gen: 4.3.0
- Fast DDS: 3.6.2.0
- CycloneDDS idlc: 11.0.1
- OpenDDS: 3.34.0
- Java runtime used by Fast DDS-Gen: OpenJDK / Temurin 21.0.11

### Platform/Architecture

Ubuntu Focal 20.04 amd64

### Transport layer

Intra-process

### Additional context

_No response_

### XML configuration file

```xml

Relevant log output

Network traffic capture

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions