Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"error: Duplicates declaration" when initializing struct in function with integer values #2261

Closed
fruffy opened this issue Mar 24, 2020 · 0 comments
Assignees
Labels
bug This behavior is unintended and should be fixed. fixed This topic is considered to be fixed.

Comments

@fruffy
Copy link
Collaborator

fruffy commented Mar 24, 2020

Hello,
I have a question. After commit 259b2e4 I am hitting this error a lot:

random/crash_bugs/A10W2_1279.p4(22): [--Werror=duplicate] error: eth_hdr: Duplicates declaration eth_hdr                                                        
    nested_struct tmp_struct = { { 0, 0, 0 } };                                 
                                 ^^^^^^^^^^^                                    
random/crash_bugs/A10W2_1279.p4(11)                                             
    ethernet_t eth_hdr;                                                         
               ^^^^^^^                                                          
random/crash_bugs/A10W2_1279.p4(22): [--Werror=duplicate] error: dst_addr: Duplicates declaration dst_addr                                                      
    nested_struct tmp_struct = { { 0, 0, 0 } };                                 
                                   ^                                            
random/crash_bugs/A10W2_1279.p4(5)                                              
    bit<48> dst_addr;                                                           
            ^^^^^^^^                                                            
random/crash_bugs/A10W2_1279.p4(22): [--Werror=duplicate] error: src_addr: Duplicates declaration src_addr                                                      
    nested_struct tmp_struct = { { 0, 0, 0 } };                                 
                                      ^                                         
random/crash_bugs/A10W2_1279.p4(6)                                              
    bit<48> src_addr;                                                           
            ^^^^^^^^                                                            
random/crash_bugs/A10W2_1279.p4(22): [--Werror=duplicate] error: eth_type: Duplicates declaration eth_type                                                      
    nested_struct tmp_struct = { { 0, 0, 0 } };                                 
                                         ^                                      
random/crash_bugs/A10W2_1279.p4(7)                                              
    bit<16> eth_type;                                                           
            ^^^^^^^^

when a structure is declared in a function and I use integer values to initialize. Is this an intentional restriction? It does not seem so.
Sample program attached.

duplicate_declaration.p4.txt

@fruffy fruffy changed the title error: Duplicates declaration when initi error: Duplicates declaration when initializing struct in function Mar 24, 2020
@fruffy fruffy changed the title error: Duplicates declaration when initializing struct in function "error: Duplicates declaration" when initializing struct in function with Integer values Mar 24, 2020
@fruffy fruffy changed the title "error: Duplicates declaration" when initializing struct in function with Integer values "error: Duplicates declaration" when initializing struct in function with integer values Mar 24, 2020
@mihaibudiu mihaibudiu self-assigned this Mar 24, 2020
@mihaibudiu mihaibudiu added the bug This behavior is unintended and should be fixed. label Mar 24, 2020
mihaibudiu pushed a commit to mihaibudiu/p4c-clone that referenced this issue Mar 24, 2020
@mihaibudiu mihaibudiu added the fixed This topic is considered to be fixed. label Mar 24, 2020
mihaibudiu pushed a commit to mihaibudiu/p4c-clone that referenced this issue Mar 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This behavior is unintended and should be fixed. fixed This topic is considered to be fixed.
Projects
None yet
Development

No branches or pull requests

2 participants